pub struct FmtTryWriter<F1>(/* private fields */);
Expand description
A writer that calls write_str
for each formatted chunk, but do not require allocations.
Write function can return either ()
or fmt::Result
.
Writer propagates error to the caller if the write function returns Result::Err
.
Note that the error context will be lost, because fmt::Error
does not support transmission of an error other than that an error occurred.
Implementations§
Source§impl<F1> FmtTryWriter<F1>where
F1: WriteStr,
impl<F1> FmtTryWriter<F1>where
F1: WriteStr,
Sourcepub fn new(write: F1) -> Self
pub fn new(write: F1) -> Self
Creates a new FmtTryWriter
from an object that implements WriteStr
.
Sourcepub fn from_closure<F, Ts>(closure: F) -> Selfwhere
F: IntoTryWriteFn<Ts, TryWriteFn = F1>,
pub fn from_closure<F, Ts>(closure: F) -> Selfwhere
F: IntoTryWriteFn<Ts, TryWriteFn = F1>,
Creates a new FmtTryWriter
with a WriteStr
wrapper
deduced with IntoTryWriteFn
by the closure signature and constructed from it.
Source§impl<F1> FmtTryWriter<F1>where
Self: Write,
impl<F1> FmtTryWriter<F1>where
Self: Write,
Sourcepub fn write_fmt(&mut self, args: Arguments<'_>) -> Result
pub fn write_fmt(&mut self, args: Arguments<'_>) -> Result
Writes a formatted string into this writer, returning any error encountered.
This method is primarily used to interface with the format_args!
macro,
but it is rare that this should explicitly be called.
The write!
macro should be favored to invoke this method instead.
Trait Implementations§
Source§impl<F1: Clone> Clone for FmtTryWriter<F1>
impl<F1: Clone> Clone for FmtTryWriter<F1>
Source§fn clone(&self) -> FmtTryWriter<F1>
fn clone(&self) -> FmtTryWriter<F1>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more