diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 76a40dc8a528a..73de423cbc001 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -1175,6 +1175,20 @@ impl Debug for [T] { } } +#[stable(feature = "lowerhex_debug", since = "1.2.0")] +impl LowerHex for [T] { + fn fmt(&self, f: &mut Formatter) -> Result { + f.debug_list().entries(self.iter()).finish() + } +} + +#[stable(feature = "lowerhex_debug", since = "1.2.0")] +impl UpperHex for [T] { + fn fmt(&self, f: &mut Formatter) -> Result { + f.debug_list().entries(self.iter()).finish() + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Debug for () { fn fmt(&self, f: &mut Formatter) -> Result { diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index c8adb6ccc0ab8..211f04a145aed 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -77,6 +77,13 @@ pub fn main() { t!(format!("{:o}", 10_usize), "12"); t!(format!("{:x}", 10_usize), "a"); t!(format!("{:X}", 10_usize), "A"); + + t!(format!("{:x}", [100]), "[0x64]"); + t!(format!("{:X}", [100]), "[0X64]"); + + t!(format!("{:?}", [100]), "[100]"); + t!(format!("{:?}", [100]), "[100]"); + t!(format!("{}", "foo"), "foo"); t!(format!("{}", "foo".to_string()), "foo"); if cfg!(target_pointer_width = "32") {