Function fmt2io::write [−][src]
pub fn write<R, W, F>(writer: W, f: F) -> Result<R> where
W: Write,
F: FnOnce(&mut Writer<W>) -> Result<R, Error>,
Expand description
Converts given io::Write
r to fmt::Write
r
The Writer
is constructed from your writer
which you
can use to write UTF-8 data to. The function returns underlying io
Error, if there has been one.
This function uses closure instead of directly exposing Writer
in order to make error handling ergonomic/idiomatic.
Panics
This function panics if writer
didn’t return an error but you
return Err
from the closure. Return Ok(Err(YourError))
to handle
your own error cases.