Only require a mutable borrow by using option's take().

This commit is contained in:
Tom Alexander 2022-12-10 21:36:22 -05:00
parent bb4b045aa8
commit 7ba863118f
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 2 additions and 2 deletions

View File

@ -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 =