std: make .swap_remove return Option<T>.

This is one of the last raw "indexing" method on vectors that returns
`T` instead of the Option.
This commit is contained in:
Huon Wilson 2014-02-23 10:56:38 +11:00 committed by Alex Crichton
parent 3ca01676bc
commit 16e635cdfb
3 changed files with 35 additions and 27 deletions

View file

@ -139,7 +139,7 @@ impl StackPool {
pub fn take_stack(&mut self, min_size: uint) -> Stack {
// Ideally this would be a binary search
match self.stacks.iter().position(|s| min_size <= s.min_size) {
Some(idx) => self.stacks.swap_remove(idx),
Some(idx) => self.stacks.swap_remove(idx).unwrap(),
None => Stack::new(min_size)
}
}