auto merge of : Gankro/rust/vec_flow, r=alexcrichton

fixes 
This commit is contained in:
bors 2014-08-03 11:36:07 +00:00
commit 845ff6567f

@ -964,7 +964,7 @@ impl<T> Vec<T> {
#[inline]
pub fn swap_remove(&mut self, index: uint) -> Option<T> {
let length = self.len();
if index < length - 1 {
if length > 0 && index < length - 1 {
self.as_mut_slice().swap(index, length - 1);
} else if index >= length {
return None
@ -2003,6 +2003,12 @@ mod tests {
let _ = vec[3];
}
#[test]
fn test_swap_remove_empty() {
let mut vec: Vec<uint> = vec!();
assert_eq!(vec.swap_remove(0), None);
}
#[bench]
fn bench_new(b: &mut Bencher) {
b.iter(|| {