more idiomatic
This commit is contained in:
parent
4319534b6b
commit
45389910ac
1 changed files with 3 additions and 7 deletions
10
src/main.rs
10
src/main.rs
|
|
@ -31,17 +31,13 @@ impl List {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pop(&mut self) -> Option<i32> {
|
pub fn pop(&mut self) -> Option<i32> {
|
||||||
let result;
|
|
||||||
match std::mem::replace(&mut self.head, Link::Empty) {
|
match std::mem::replace(&mut self.head, Link::Empty) {
|
||||||
Link::Empty => {
|
Link::Empty => None,
|
||||||
result = None;
|
|
||||||
}
|
|
||||||
Link::More(node) => {
|
Link::More(node) => {
|
||||||
result = Some(node.elem);
|
|
||||||
self.head = node.next;
|
self.head = node.next;
|
||||||
|
Some(node.elem)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
result
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue