#io-write #write #io #fmt #bridge #wrapper

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

#1833 in Rust patterns

Download history 796/week @ 2024-03-17 730/week @ 2024-03-24 741/week @ 2024-03-31 740/week @ 2024-04-07 735/week @ 2024-04-14 1066/week @ 2024-04-21 955/week @ 2024-04-28 667/week @ 2024-05-05 617/week @ 2024-05-12 750/week @ 2024-05-19 734/week @ 2024-05-26 691/week @ 2024-06-02 609/week @ 2024-06-09 711/week @ 2024-06-16 699/week @ 2024-06-23 471/week @ 2024-06-30

2,552 downloads per month
Used in 30 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