A collection of methods that are required to format a message into a stream.
This trait is the type which this modules requires when formatting information. This is similar to the standard library's io::Write trait, but it is only intended for use in libcore.
This trait should generally not be implemented by consumers of the standard library. The write! macro accepts an instance of io::Write, and the io::Write trait is favored over implementing this trait.
It seems the main reason fmt::Write
exists at all is just because core::io
stubbornly refuses to exist. Why doesn't it again? Aside from adding io
to core
, one possible solution to the Write
ambiguity would be to have Error
be an associated type to fmt::Result
. For String
, Error
would be !
, and io::Write
could be aliased to fmt::Write<Error=io::Error>
.
I would absolutely love to be able to use write!()
without importing. Heck, would it possible for core::write!()
itself to use core::fmt::Write;
and std::write!()
to use std::io::Write;
?
If core::io
was a thing, then fmt::Write
could just be deleted entirely, or simply deprecated for backwards compatibility.