use comet::GCPlatform; use comet_api::{*,cell::Heap}; struct Node { next: Option>>, value: T } impl GcCell for Node {} impl Trace for Node { fn trace(&self, vis: &mut Visitor) { println!("Trace {:p} {:?}",self,self); self.value.trace(vis); self.next.trace(vis); } } impl Finalize for Node {} impl std::fmt::Debug for Node { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f,"Node {{next: {:?}, value: {:?} }}",self.next,self.value) } } impl Drop for Node { fn drop(&mut self) { println!("drop {:p} {:?}",self,self); } } fn main() { GCPlatform::initialize(); let mut heap = Heap::new(None); let mut head = heap.allocate(Node {next: None,value: 0i32 }); head.next = Some(heap.allocate(Node {next: None, value: 1})); heap.gc(); println!("{:p}",&head); head.next = None; heap.gc(); println!("{:p}", &head); }