Only require a mutable borrow by using option's take().
This commit is contained in:
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user