The docs for std::fmt::Write discourage using it outside of the standard library:
[…] 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.
Yet it is relatively often that one needs a trait for writing Unicode to a stream. For example, pulldown-cmark has a trait very similar to this one called StrWrite.
When I asked in Zulip, nobody seemed to know why that comment is there.
It would be good to have a standard that every library can use for this.
@rustbot modify labels: A-fmt T-libs T-doc
The docs for
std::fmt::Writediscourage using it outside of the standard library:Yet it is relatively often that one needs a trait for writing Unicode to a stream. For example,
pulldown-cmarkhas a trait very similar to this one calledStrWrite.When I asked in Zulip, nobody seemed to know why that comment is there.
It would be good to have a standard that every library can use for this.
@rustbot modify labels: A-fmt T-libs T-doc