Skip to main content

WriteStr

Trait WriteStr 

Source
pub trait WriteStr {
    // Required methods
    fn write_str(&mut self, s: &str) -> Result<()>;
    fn write_str_flush(&mut self) -> Result<()>;

    // Provided methods
    fn write_char(&mut self, c: char) -> Result<()> { ... }
    fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<()> { ... }
}
Expand description

A trait that abstracts over writing strings to a writer.

For more, see the module-level documentation.

Required Methods§

Source

fn write_str(&mut self, s: &str) -> Result<()>

Writes a string to the writer.

Source

fn write_str_flush(&mut self) -> Result<()>

Flushes the writer, ensuring that all intermediately buffered contents reach their destination.

Provided Methods§

Source

fn write_char(&mut self, c: char) -> Result<()>

Writes a single character to the writer.

Source

fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<()>

Writes a formatted string to the writer.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl WriteStr for String

Source§

fn write_str(&mut self, s: &str) -> Result<()>

Source§

fn write_str_flush(&mut self) -> Result<()>

Source§

fn write_char(&mut self, c: char) -> Result<()>

Source§

impl<T: WriteStr + ?Sized> WriteStr for &mut T

Source§

fn write_str(&mut self, s: &str) -> Result<()>

Source§

fn write_str_flush(&mut self) -> Result<()>

Source§

fn write_char(&mut self, c: char) -> Result<()>

Source§

fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<()>

Source§

impl<W: Write> WriteStr for BufWriter<W>

Source§

fn write_str(&mut self, s: &str) -> Result<()>

Source§

fn write_str_flush(&mut self) -> Result<()>

Source§

fn write_char(&mut self, c: char) -> Result<()>

Implementors§

Source§

impl WriteStr for PagedOutput

Source§

impl<T> WriteStr for Indented<'_, T>
where T: WriteStr + ?Sized,