#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

#1221 in Rust patterns

Download history 1567/week @ 2022-10-08 3047/week @ 2022-10-15 1793/week @ 2022-10-22 1989/week @ 2022-10-29 2302/week @ 2022-11-05 2298/week @ 2022-11-12 1584/week @ 2022-11-19 1549/week @ 2022-11-26 1424/week @ 2022-12-03 1408/week @ 2022-12-10 1522/week @ 2022-12-17 1586/week @ 2022-12-24 1797/week @ 2022-12-31 1594/week @ 2023-01-07 1843/week @ 2023-01-14 1318/week @ 2023-01-21

6,755 downloads per month
Used in 30 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