diff options
| author | bors <bors@rust-lang.org> | 2014-02-13 15:17:21 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-02-13 15:17:21 -0800 |
| commit | 94d453e459107ed1c5d76f693686b29d31cdc58c (patch) | |
| tree | b586a7c785fa57253b3ba1bcaaee5ae1ea167411 /src/libstd/ascii.rs | |
| parent | cfb87f10ec7d41d0e7f8c68fbb908fc195517d41 (diff) | |
| parent | 640b22852f59e4505cedfd02c01cc343d5ec0d9e (diff) | |
| download | rust-94d453e459107ed1c5d76f693686b29d31cdc58c.tar.gz rust-94d453e459107ed1c5d76f693686b29d31cdc58c.zip | |
auto merge of #12248 : alexcrichton/rust/rollup, r=alexcrichton
This passed `make check` locally, so hopefully it passes on bors!
Diffstat (limited to 'src/libstd/ascii.rs')
| -rw-r--r-- | src/libstd/ascii.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 7965127007c..651d364dd1b 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -17,6 +17,7 @@ use str::StrSlice; use str::OwnedStr; use container::Container; use cast; +use fmt; use iter::Iterator; use vec::{ImmutableVector, MutableVector, Vector}; use to_bytes::IterBytes; @@ -134,6 +135,12 @@ impl ToStr for Ascii { } } +impl<'a> fmt::Show for Ascii { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + (self.chr as char).fmt(f) + } +} + /// Trait for converting into an ascii type. pub trait AsciiCast<T> { /// Convert to an ascii type, fail on non-ASCII input. @@ -698,5 +705,9 @@ mod tests { assert_eq!(s, ~"t"); } - + #[test] + fn test_show() { + let c = Ascii { chr: 't' as u8 }; + assert_eq!(format!("{}", c), ~"t"); + } } |
