diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2015-06-10 21:41:34 +0200 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2015-06-10 22:06:18 +0200 |
| commit | 63da18b269128c6594b0fa60064b187a9b5d0418 (patch) | |
| tree | ca80d0a94c647a56f40a925d8069bd738140a23e /src/libcore | |
| parent | 15b028c5859f98b32cde69b81dd62468039db0be (diff) | |
| download | rust-63da18b269128c6594b0fa60064b187a9b5d0418.tar.gz rust-63da18b269128c6594b0fa60064b187a9b5d0418.zip | |
Have std::fmt::Formatter implement std::fmt::Write.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/fmt/mod.rs | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 34d635ca4ab..da4d24bdc7b 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -731,13 +731,6 @@ impl<'a> Formatter<'a> { self.buf.write_str(data) } - /// Writes a `char` to the underlying buffer contained within this - /// formatter. - #[stable(feature = "fmt_write_char", since = "1.1.0")] - pub fn write_char(&mut self, c: char) -> Result { - self.buf.write_char(c) - } - /// Writes some formatted information into this instance #[stable(feature = "rust1", since = "1.0.0")] pub fn write_fmt(&mut self, fmt: Arguments) -> Result { @@ -899,6 +892,21 @@ impl<'a> Formatter<'a> { } } +#[stable(since = "1.2.0", feature = "formatter_write")] +impl<'a> Write for Formatter<'a> { + fn write_str(&mut self, s: &str) -> Result { + self.buf.write_str(s) + } + + fn write_char(&mut self, c: char) -> Result { + self.buf.write_char(c) + } + + fn write_fmt(&mut self, args: Arguments) -> Result { + write(self.buf, args) + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Display for Error { fn fmt(&self, f: &mut Formatter) -> Result { |
