From 06ce6d7cc3df31193582e26aa924003f174473fb Mon Sep 17 00:00:00 2001 From: Sander Hautvast Date: Wed, 26 Jan 2022 19:07:26 +0100 Subject: [PATCH] cannot move --- src/main.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main.rs b/src/main.rs index b0a06ab..c665851 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,6 +29,20 @@ impl List { }; self.head = Link::More(Box::new(new_node)); } + + pub fn pop(&mut self) -> Option { + let result; + match &self.head { + Link::Empty => { + result = None; + } + Link::More(node) => { + result = Some(node.elem); + self.head = node.next; + } + }; + result + } } #[cfg(test)]