Skip to content

Generalize output streams and input arguments with traits

Simon Sapin requested to merge topic/default/display2 into branch/default

format_bytes! now accepts any argument that implements a new DisplayBytes trait, not just byte strings. This trait is similar to std::fmt::Display but writes to a byte stream std::io::Write instead of an Unicode stream std::fmt::Write.

write_bytes! is to format_bytes! what the standard library’s write! is to format!: instead of returning a Vec<u8> it writes to the output stream given as an additional first argument that implements the std::io::Write trait, and returns a Result.

This is a successor to !1 (closed), using std::io::Write directly instead of making a new WriteBytes trait.

Merge request reports