Skip to content

Commit

Permalink
auto merge of rust-lang#13687 : exscape/mut-vector-Show/master, r=ale…
Browse files Browse the repository at this point in the history
…xcrichton

Removes the need for hacks to println! mutable slices, among other things.
  • Loading branch information
bors committed Apr 23, 2014
2 parents 30fe550 + aa4bc89 commit 34ff34d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/libstd/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2002,6 +2002,12 @@ impl<'a, T: fmt::Show> fmt::Show for &'a [T] {
}
}

impl<'a, T: fmt::Show> fmt::Show for &'a mut [T] {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.as_slice().fmt(f)
}
}

impl<T: fmt::Show> fmt::Show for ~[T] {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.as_slice().fmt(f)
Expand Down Expand Up @@ -3408,6 +3414,12 @@ mod tests {
test_show_vec!(~[1], "[1]".to_owned());
test_show_vec!(~[1, 2, 3], "[1, 2, 3]".to_owned());
test_show_vec!(~[~[], ~[1u], ~[1u, 1u]], "[[], [1], [1, 1]]".to_owned());

let empty_mut: &mut [int] = &mut[];
test_show_vec!(empty_mut, "[]".to_owned());
test_show_vec!(&mut[1], "[1]".to_owned());
test_show_vec!(&mut[1, 2, 3], "[1, 2, 3]".to_owned());
test_show_vec!(&mut[&mut[], &mut[1u], &mut[1u, 1u]], "[[], [1], [1, 1]]".to_owned());
}

#[test]
Expand Down

0 comments on commit 34ff34d

Please sign in to comment.