#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

#2500 in Rust patterns

Download history 2233/week @ 2023-11-07 2452/week @ 2023-11-14 2762/week @ 2023-11-21 2189/week @ 2023-11-28 3643/week @ 2023-12-05 4484/week @ 2023-12-12 2139/week @ 2023-12-19 1788/week @ 2023-12-26 3112/week @ 2024-01-02 3359/week @ 2024-01-09 3420/week @ 2024-01-16 3232/week @ 2024-01-23 1970/week @ 2024-01-30 3382/week @ 2024-02-06 3055/week @ 2024-02-13 3253/week @ 2024-02-20

12,162 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