about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTobias Bucher <tobiasbucher5991@gmail.com>2014-09-14 21:33:48 +0200
committerTobias Bucher <tobiasbucher5991@gmail.com>2014-09-14 21:35:49 +0200
commit2c7f6eee0c6a3d5b67e523aa5c8dc0bd27cf8c4b (patch)
tree669b35969a06ae548fec2a49339a6a0558b0d8bb
parent7ccab3ae8aeb1b0d7002187990aaa56b1ff03d28 (diff)
downloadrust-2c7f6eee0c6a3d5b67e523aa5c8dc0bd27cf8c4b.tar.gz
rust-2c7f6eee0c6a3d5b67e523aa5c8dc0bd27cf8c4b.zip
Fixed `map_in_place` tests after rustc upgrade
This replaces the now obsolete syntax `&[]` with `[].as_slice()`.
-rw-r--r--src/libcollections/vec.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index e45eeed571a..6fc367474bb 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -1951,14 +1951,13 @@ impl<T> Vec<T> {
     /// ```
     /// let v = vec![0u, 1, 2];
     /// let w = v.map_in_place(|i| i + 3);
-    /// assert_eq!(w.as_slice(), &[3, 4, 5]);
+    /// assert_eq!(w.as_slice(), [3, 4, 5].as_slice());
     ///
-    /// let big_endian_u16s = vec![0x1122u16, 0x3344];
-    /// let u8s = big_endian_u16s.map_in_place(|x| [
-    ///     ((x >> 8) & 0xff) as u8,
-    ///     (x & 0xff) as u8
-    /// ]);
-    /// assert_eq!(u8s.as_slice(), &[[0x11, 0x22], [0x33, 0x44]]);
+    /// #[deriving(PartialEq, Show)]
+    /// struct Newtype(u8);
+    /// let bytes = vec![0x11, 0x22];
+    /// let newtyped_bytes = bytes.map_in_place(|x| Newtype(x));
+    /// assert_eq!(newtyped_bytes.as_slice(), [Newtype(0x11), Newtype(0x22)].as_slice());
     /// ```
     pub fn map_in_place<U>(self, f: |T| -> U) -> Vec<U> {
         let mut pv = PartialVec::from_vec(self);
@@ -2314,7 +2313,7 @@ mod tests {
     #[test]
     fn test_map_in_place() {
         let v = vec![0u, 1, 2];
-        assert_eq!(v.map_in_place(|i: uint| i as int - 1).as_slice(), &[-1i, 0, 1]);
+        assert_eq!(v.map_in_place(|i: uint| i as int - 1).as_slice(), [-1i, 0, 1].as_slice());
     }
 
     #[bench]