Only require a mutable borrow by using option's take().
This commit is contained in:
parent
bb4b045aa8
commit
7ba863118f
@ -35,8 +35,8 @@ impl<T: Debug> List<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pop_front(self) -> (Option<T>, List<T>) {
|
||||
match self.head {
|
||||
pub fn pop_front(&mut self) -> (Option<T>, List<T>) {
|
||||
match self.head.take() {
|
||||
None => (None, List::new()),
|
||||
Some(popped_node) => {
|
||||
let extracted_node =
|
||||
|
Loading…
x
Reference in New Issue
Block a user