about summary refs log tree commit diff
path: root/src/libstd/vec.rs
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2013-12-23 16:20:52 +0100
committerSimon Sapin <simon.sapin@exyr.org>2014-01-21 15:48:47 -0800
commitbada25e425ae30583ad343e36a034e59c66fcad6 (patch)
tree4e07ddbe72ef54075d401322c8283de064f02b4e /src/libstd/vec.rs
parentaa66b91767ce92c45192ca11718575529d631d21 (diff)
[std::vec] Rename .pop_opt() to .pop(), drop the old .pop() behavior
Diffstat (limited to 'src/libstd/vec.rs')
-rw-r--r--src/libstd/vec.rs31
1 files changed, 6 insertions, 25 deletions
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index b3d0e9cb10a..1dfd2ea5600 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -1381,10 +1381,8 @@ pub trait OwnedVector<T> {
     /// assert!(a == ~[~1, ~2, ~3, ~4]);
     /// ```
     fn push_all_move(&mut self, rhs: ~[T]);
-    /// Remove the last element from a vector and return it, failing if it is empty
-    fn pop(&mut self) -> T;
     /// Remove the last element from a vector and return it, or `None` if it is empty
-    fn pop_opt(&mut self) -> Option<T>;
+    fn pop(&mut self) -> Option<T>;
     /// Removes the first element from a vector and return it
     fn shift(&mut self) -> T;
     /// Removes the first element from a vector and return it, or `None` if it is empty
@@ -1565,7 +1563,7 @@ impl<T> OwnedVector<T> for ~[T] {
         }
     }
 
-    fn pop_opt(&mut self) -> Option<T> {
+    fn pop(&mut self) -> Option<T> {
         match self.len() {
             0  => None,
             ln => {
@@ -1580,11 +1578,6 @@ impl<T> OwnedVector<T> for ~[T] {
 
 
     #[inline]
-    fn pop(&mut self) -> T {
-        self.pop_opt().expect("pop: empty vector")
-    }
-
-    #[inline]
     fn shift(&mut self) -> T {
         self.shift_opt().expect("shift: empty vector")
     }
@@ -3168,28 +3161,16 @@ mod tests {
         assert_eq!(vec.slice_to(0), &[]);
     }
 
-    #[test]
-    fn test_pop() {
-        // Test on-heap pop.
-        let mut v = ~[1, 2, 3, 4, 5];
-        let e = v.pop();
-        assert_eq!(v.len(), 4u);
-        assert_eq!(v[0], 1);
-        assert_eq!(v[1], 2);
-        assert_eq!(v[2], 3);
-        assert_eq!(v[3], 4);
-        assert_eq!(e, 5);
-    }
 
     #[test]
-    fn test_pop_opt() {
+    fn test_pop() {
         let mut v = ~[5];
-        let e = v.pop_opt();
+        let e = v.pop();
         assert_eq!(v.len(), 0);
         assert_eq!(e, Some(5));
-        let f = v.pop_opt();
+        let f = v.pop();
         assert_eq!(f, None);
-        let g = v.pop_opt();
+        let g = v.pop();
         assert_eq!(g, None);
     }