about summary refs log tree commit diff
path: root/src/libstd/vec_ng.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd/vec_ng.rs')
-rw-r--r--src/libstd/vec_ng.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/libstd/vec_ng.rs b/src/libstd/vec_ng.rs
index 3532e7b26a4..2f39adc25d3 100644
--- a/src/libstd/vec_ng.rs
+++ b/src/libstd/vec_ng.rs
@@ -277,15 +277,14 @@ impl<T> Vec<T> {
     }
 
     #[inline]
-    pub fn swap_remove(&mut self, index: uint) -> T {
+    pub fn swap_remove(&mut self, index: uint) -> Option<T> {
         let length = self.len();
-        if index >= length {
-            fail!("Vec::swap_remove - index {} >= length {}", index, length);
-        }
         if index < length - 1 {
             self.as_mut_slice().swap(index, length - 1);
+        } else if index >= length {
+            return None
         }
-        self.pop().unwrap()
+        self.pop()
     }
 
     #[inline]
@@ -392,4 +391,3 @@ impl<T> Drop for MoveItems<T> {
         }
     }
 }
-