-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Hi folks,
I've been poking around in data structures and I need to remove an element from this linked list (it stores a reference of a trait). My code is basically:
pub fn remove(&mut self, timer: &'a T) {
// other stuff.
let mut cursor = list.cursor();
loop {
let next = cursor.peek_next();
if next.is_some() {
if *(next.unwrap()) as *const T == timer as *const T {
cursor.remove();
break;
}
cursor.seek_forward(1);
} else {
break;
}
}
}Now this doesn't work because remove and/or seek_forward borrow mut, but the peek_next did already. I think in this case what I'd need would be a peek which doesn't return a mut, right? Can we put that in or is there an obvious solution that I don't know about?
@gankro wdyt?
Metadata
Metadata
Assignees
Labels
No labels