mirror of
https://github.com/rust-lang/rust.git
synced 2026-06-02 06:28:20 +03:00
Implement Show for &mut [T]
This commit is contained in:
@@ -2002,6 +2002,12 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -3408,6 +3414,12 @@ macro_rules! test_show_vec(
|
||||
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]
|
||||
|
||||
Reference in New Issue
Block a user