cannot move

This commit is contained in:
Sander Hautvast 2022-01-26 19:07:26 +01:00
parent ae2d94d6f8
commit 06ce6d7cc3

View file

@ -29,6 +29,20 @@ impl List {
}; };
self.head = Link::More(Box::new(new_node)); self.head = Link::More(Box::new(new_node));
} }
pub fn pop(&mut self) -> Option<i32> {
let result;
match &self.head {
Link::Empty => {
result = None;
}
Link::More(node) => {
result = Some(node.elem);
self.head = node.next;
}
};
result
}
} }
#[cfg(test)] #[cfg(test)]