diff --git a/src/listhead.rs b/src/listhead.rs index a05e6c8..0cac040 100644 --- a/src/listhead.rs +++ b/src/listhead.rs @@ -74,11 +74,14 @@ impl ListHead { head.borrow_mut().init(); } - pub fn for_each(&self, cb: fn () -> i64) { - let pos = self.next.clone(); + pub fn for_each(&self, cb: fn (&Weak::>) -> bool) { + let mut pos = self.next.clone(); let self_weak = &Rc::downgrade(&self.get_rc_refcell()); while !Weak::ptr_eq(&pos, self_weak) { - + if !cb(&pos.upgrade().unwrap().borrow().data()) { + break; + } + pos = pos.upgrade().unwrap().borrow().next.clone(); } }