#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

#1716 in Rust patterns

Download history 2994/week @ 2024-01-18 2647/week @ 2024-01-25 1943/week @ 2024-02-01 3361/week @ 2024-02-08 3186/week @ 2024-02-15 3862/week @ 2024-02-22 3446/week @ 2024-02-29 2870/week @ 2024-03-07 883/week @ 2024-03-14 737/week @ 2024-03-21 796/week @ 2024-03-28 698/week @ 2024-04-04 745/week @ 2024-04-11 759/week @ 2024-04-18 1196/week @ 2024-04-25 633/week @ 2024-05-02

3,436 downloads per month
Used in 29 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