cannot move
This commit is contained in:
parent
ae2d94d6f8
commit
06ce6d7cc3
1 changed files with 14 additions and 0 deletions
14
src/main.rs
14
src/main.rs
|
|
@ -29,6 +29,20 @@ impl List {
|
|||
};
|
||||
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)]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue