Closed ChenZhongPu closed 2 years ago
The pop function in fifth.rs can be simplified:
pop
pub fn pop(&mut self) -> Option<T> { self.head.take().map(|head| { let head = *head; self.head = head.next; if self.head.is_none() { self.tail = ptr::null_mut(); } head.elem }) }
Due to the auto-deref, let head = *head; can be removed.
let head = *head;
This section has been completely rewritten. Any of the old code is now a large "failed experiment" that leads into the "right" implementation, so I'm fine with it having some slop.
The
pop
function in fifth.rs can be simplified:Due to the auto-deref,
let head = *head;
can be removed.