Skip to content

Commit

Permalink
Fixed map_in_place tests after rustc upgrade
Browse files Browse the repository at this point in the history
This replaces the now obsolete syntax `&[]` with `[].as_slice()`.
  • Loading branch information
tbu- committed Sep 14, 2014
1 parent 7ccab3a commit 2c7f6ee
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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]
Expand Down

5 comments on commit 2c7f6ee

@bors
Copy link
Contributor

@bors bors commented on 2c7f6ee Sep 15, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from aturon
at tbu-@2c7f6ee

@bors
Copy link
Contributor

@bors bors commented on 2c7f6ee Sep 15, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging tbu-/rust/pr_mapinplace = 2c7f6ee into auto

@bors
Copy link
Contributor

@bors bors commented on 2c7f6ee Sep 15, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbu-/rust/pr_mapinplace = 2c7f6ee merged ok, testing candidate = e4771d1

@bors
Copy link
Contributor

@bors bors commented on 2c7f6ee Sep 15, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 2c7f6ee Sep 15, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = e4771d1

Please sign in to comment.