Skip to content

Commit

Permalink
Add a blanket impl for &mut std::fmt::Write
Browse files Browse the repository at this point in the history
There is already a corresponding impl for `std::io::Write`. This change
will make the two traits more consistent.
  • Loading branch information
lambda-fairy committed Sep 12, 2015
1 parent 50a6c79 commit 2305dc0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,21 @@ pub trait Write {
}
}

#[stable(feature = "fmt_write_blanket_impl", since = "1.4.0")]
impl<'a, W: Write + ?Sized> Write for &'a mut W {
fn write_str(&mut self, s: &str) -> Result {
(**self).write_str(s)
}

fn write_char(&mut self, c: char) -> Result {
(**self).write_char(c)
}

fn write_fmt(&mut self, args: Arguments) -> Result {
(**self).write_fmt(args)
}
}

/// A struct to represent both where to emit formatting strings to and how they
/// should be formatted. A mutable version of this is passed to all formatting
/// traits.
Expand Down

0 comments on commit 2305dc0

Please sign in to comment.