Fixed map_in_place tests after rustc upgrade

This replaces the now obsolete syntax `&[]` with `[].as_slice()`.
This commit is contained in:
Tobias Bucher 2014-09-14 21:33:48 +02:00
parent 7ccab3ae8a
commit 2c7f6eee0c

View File

@ -1951,14 +1951,13 @@ impl<T> Vec<T> {
/// ``` /// ```
/// let v = vec![0u, 1, 2]; /// let v = vec![0u, 1, 2];
/// let w = v.map_in_place(|i| i + 3); /// 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]; /// #[deriving(PartialEq, Show)]
/// let u8s = big_endian_u16s.map_in_place(|x| [ /// struct Newtype(u8);
/// ((x >> 8) & 0xff) as u8, /// let bytes = vec![0x11, 0x22];
/// (x & 0xff) as u8 /// let newtyped_bytes = bytes.map_in_place(|x| Newtype(x));
/// ]); /// assert_eq!(newtyped_bytes.as_slice(), [Newtype(0x11), Newtype(0x22)].as_slice());
/// assert_eq!(u8s.as_slice(), &[[0x11, 0x22], [0x33, 0x44]]);
/// ``` /// ```
pub fn map_in_place<U>(self, f: |T| -> U) -> Vec<U> { pub fn map_in_place<U>(self, f: |T| -> U) -> Vec<U> {
let mut pv = PartialVec::from_vec(self); let mut pv = PartialVec::from_vec(self);
@ -2314,7 +2313,7 @@ mod tests {
#[test] #[test]
fn test_map_in_place() { fn test_map_in_place() {
let v = vec![0u, 1, 2]; 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] #[bench]