Struct custom_print::FmtTryWriter
source · pub struct FmtTryWriter<F1>(_);
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§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<F1: Debug> Debug for FmtTryWriter<F1>
impl<F1: Debug> Debug for FmtTryWriter<F1>
source§impl<F1: PartialEq> PartialEq<FmtTryWriter<F1>> for FmtTryWriter<F1>
impl<F1: PartialEq> PartialEq<FmtTryWriter<F1>> for FmtTryWriter<F1>
source§fn eq(&self, other: &FmtTryWriter<F1>) -> bool
fn eq(&self, other: &FmtTryWriter<F1>) -> bool
self
and other
values to be equal, and is used
by ==
.