pub trait HasSpaces {
type VM: VMBinding;
// Required methods
fn for_each_space(&self, func: &mut dyn FnMut(&dyn Space<Self::VM>));
fn for_each_space_mut(
&mut self,
func: &mut dyn FnMut(&mut dyn Space<Self::VM>)
);
}
Expand description
A trait for anything that contains spaces.
Examples include concrete plans as well as Gen
, CommonPlan
and BasePlan
.
All plans must implement this trait.
This trait provides methods for enumerating spaces in a struct, including spaces in nested struct.
This trait can be implemented automatically by adding the #[derive(HasSpaces)]
attribute to a
struct. It uses the derive macro defined in the mmtk-macros
crate.
This trait visits spaces as dyn
, so it should only be used when performance is not critical.
For performance critical methods that visit spaces in a plan, such as trace_object
, it is
recommended to define a trait (such as PlanTraceObject
) for concrete plans to implement, and
implement (by hand or automatically) the method without dyn
.
Required Associated Types§
Required Methods§
sourcefn for_each_space(&self, func: &mut dyn FnMut(&dyn Space<Self::VM>))
fn for_each_space(&self, func: &mut dyn FnMut(&dyn Space<Self::VM>))
Visit each space field immutably.
If Self
contains nested fields that contain more spaces, this method shall visit spaces
in the outer struct first.
sourcefn for_each_space_mut(&mut self, func: &mut dyn FnMut(&mut dyn Space<Self::VM>))
fn for_each_space_mut(&mut self, func: &mut dyn FnMut(&mut dyn Space<Self::VM>))
Visit each space field mutably.
If Self
contains nested fields that contain more spaces, this method shall visit spaces
in the outer struct first.