Expand description
Have you ever implemented a nice algorithm that generically uses fmt::Write
only to find out it doesn’t work with io::Write? Worry no more - this is the
solution!
This crate provides a simple write function which takes your io::Writer,
converts it to fmt::Writer and provides it to your closure. This way, you
can easily bridge the two traits and have truly generic code.
§Example
let mut out = Vec::new();
use std::fmt::Write;
fmt2io::write(&mut out, |writer| write!(writer, "Hello world!"))?;
assert_eq!(out, "Hello world!".as_bytes());
Structs§
- A bridge between
std::io::Writeandstd::fmt::Write.
Functions§
- Converts given
io::Writer tofmt::Writer.