-
-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
format_into()
requires io::Write
; what about fmt::Write
in Debug/Display impls?
#375
Comments
@CryZe messaged me yesterday about this, actually. He's working on a PR that would do this in a backwards-compatible way. |
It would be nice to make To summarize, the three use cases can each be made available behind different feature gates:
|
The primary problem that formatting into That said, the existing |
No, but it could be made available under a |
It has to be under a different method name. Feature gates can't change a method signature. |
Sorry about the possible confusion, but I'm not asking to modify the signature of I think this proposal needs to be discussed as its own issue; formatting into |
That's got to be already solved for |
This inherently requires a new method, as the existing signature requires
Right now |
Ah, but changing the return type to
Understood, it will be more difficult with incremental output and no allocations. |
Hmm...you may be right after ~30 seconds of looking at code. It may be possible to have |
As I just mentioned in #407, my current intent is to wait for |
Simple (and the most common, I believe) use case - you're implementing
Display
orDebug
for your type containing some time objects, and you are provided withstd::fmt::Formatter
which implementsstd::fmt::Write
trait. (maybe I'm missing something trivial, so apologies in advance if that's the case)Current
format_into
implementations though require&mut impl std::io::Write
which is a different beast, more complex and aimed at different stuff, with vectored writes, flushing and all the rest. If one were to choose between the two, wouldn't it make sense to supportfmt::Write
and notio::Write
? Is there a clean alternative way?(There's crates like
fmt2io
that provide hacky bridges but that's just ugly and wrong)The text was updated successfully, but these errors were encountered: