#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

#2003 in Rust patterns

Download history 1839/week @ 2023-10-15 1582/week @ 2023-10-22 1466/week @ 2023-10-29 2062/week @ 2023-11-05 2424/week @ 2023-11-12 2780/week @ 2023-11-19 2384/week @ 2023-11-26 3083/week @ 2023-12-03 4501/week @ 2023-12-10 2804/week @ 2023-12-17 1295/week @ 2023-12-24 3419/week @ 2023-12-31 2904/week @ 2024-01-07 3549/week @ 2024-01-14 3355/week @ 2024-01-21 2002/week @ 2024-01-28

11,896 downloads per month
Used in 28 crates (3 directly)

MITNFA license

5KB

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