mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 18:23:49 +00:00
Have std::fmt::Formatter implement std::fmt::Write.
This commit is contained in:
parent
15b028c585
commit
63da18b269
@ -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 {
|
||||
|
@ -15,7 +15,7 @@
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::fmt;
|
||||
use std::fmt::{self, Write};
|
||||
use std::usize;
|
||||
|
||||
struct A;
|
||||
|
Loading…
Reference in New Issue
Block a user