Skip to content

Commit 34ff34d

Browse files
committed
auto merge of #13687 : exscape/mut-vector-Show/master, r=alexcrichton
Removes the need for hacks to println! mutable slices, among other things.
2 parents 30fe550 + aa4bc89 commit 34ff34d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/libstd/slice.rs

+12
Original file line numberDiff line numberDiff line change
@@ -2002,6 +2002,12 @@ impl<'a, T: fmt::Show> fmt::Show for &'a [T] {
20022002
}
20032003
}
20042004

2005+
impl<'a, T: fmt::Show> fmt::Show for &'a mut [T] {
2006+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2007+
self.as_slice().fmt(f)
2008+
}
2009+
}
2010+
20052011
impl<T: fmt::Show> fmt::Show for ~[T] {
20062012
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
20072013
self.as_slice().fmt(f)
@@ -3408,6 +3414,12 @@ mod tests {
34083414
test_show_vec!(~[1], "[1]".to_owned());
34093415
test_show_vec!(~[1, 2, 3], "[1, 2, 3]".to_owned());
34103416
test_show_vec!(~[~[], ~[1u], ~[1u, 1u]], "[[], [1], [1, 1]]".to_owned());
3417+
3418+
let empty_mut: &mut [int] = &mut[];
3419+
test_show_vec!(empty_mut, "[]".to_owned());
3420+
test_show_vec!(&mut[1], "[1]".to_owned());
3421+
test_show_vec!(&mut[1, 2, 3], "[1, 2, 3]".to_owned());
3422+
test_show_vec!(&mut[&mut[], &mut[1u], &mut[1u, 1u]], "[[], [1], [1, 1]]".to_owned());
34113423
}
34123424

34133425
#[test]

0 commit comments

Comments
 (0)