Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub fn pop(&mut self) -> Option<i32> {
- match mem::replace(&mut self.head, Link::Empty) {
- Link::Empty => None,
- Link::More(boxed_node) => {
- let node = *boxed_node;
- self.head = node.next;
- Some(node.elem)
- }
- }
- }
- pub fn pop(&mut self) -> Option<i32> {
- match mem::replace(&mut self.head, Link::Empty) {
- Link::Empty => None,
- Link::More(node) => {
- self.head = node.next;
- Some(node.elem)
- }
- }
- }
- struct Node {
- elem: i32,
- next: Link,
- }
- enum Link {
- Empty,
- More(Box<Node>),
- }
Add Comment
Please, Sign In to add comment