#fmt #io #write #wrapper #bridge

fmt2io

A bridge between std::io::Write and std::fmt::Write

2 unstable releases

Uses old Rust 2015

0.2.0 Jun 22, 2021
0.1.0 Nov 6, 2018

#351 in Rust patterns

Download history 1904/week @ 2021-10-05 1907/week @ 2021-10-12 1572/week @ 2021-10-19 1584/week @ 2021-10-26 1534/week @ 2021-11-02 1538/week @ 2021-11-09 1924/week @ 2021-11-16 1380/week @ 2021-11-23 1516/week @ 2021-11-30 1901/week @ 2021-12-07 1633/week @ 2021-12-14 1191/week @ 2021-12-21 1113/week @ 2021-12-28 923/week @ 2022-01-04 1585/week @ 2022-01-11 1245/week @ 2022-01-18

5,072 downloads per month
Used in 13 crates (3 directly)

MITNFA license

4KB

Fmt to IO

A bridge between std::io::Write and std::fmt::Write.

About

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.

License

MITNFA


lib.rs:

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!")).unwrap();
assert_eq!(out, "Hello world!".as_bytes());

No runtime deps