use std::fmt::Debug;
pub unsafe trait Trace: Debug {
fn mark_children(&self);
}
macro_rules! impl_nop_trace {
($ty:ty) => {
unsafe impl Trace for $ty {
fn mark_children(&self) {}
}
};
($( $ty:ty ) ,*) => {
$( impl_nop_trace!($ty); )*
};
}
impl_nop_trace!(i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, bool, char, String, ());
unsafe impl<T: Trace> Trace for &T {
fn mark_children(&self) {
(*self).mark_children();
}
}
unsafe impl<T: Trace> Trace for &[T] {
fn mark_children(&self) {
for item in self.iter() {
item.mark_children();
}
}
}