-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Figure out the default ifmt
trait
#8489
Comments
|
cc #8089 |
For (On this note, it be neat if we could somehow allow It might also be a nice simplification to remove all of @blake2-ppc: it is easy to update |
I have no strong opinion on this, aside from " |
From what I've been talking about with @huonw and @blake2-ppc we're all in agreement that
I'm personally still leaning towards In the far future, python has formats like @huonw, @blake2-ppc, with this in mind, do you guys still think that |
Right now an implementation of |
I'd (embarrassingly) forgotten about the precision & width arguments, so I agree that we need a separate trait for |
See discussion in #8489, but this selects option 3 by adding a `Default` trait to be implemented by various basic types. Once this makes it into a snapshot I think it's about time to start overhauling all current use-cases of `fmt!` to move towards `ifmt!`. The goal is to replace `%X` with `{}` in 90% of situations, and this commit should enable that.
Closed by #8564 |
Add `unnecessary_find_map` lint This PR adds an `unnecessary_find_map` lint. It is essentially just a minor enhancement of `unnecessary_filter_map`. Closes rust-lang#8467 changelog: New lint `unnecessary_find_map`
When using
ifmt
, a format argument can be simple as{}
which means "the next argument" formatted as "the default". Currently the default is the?
orfmt::Poly
format trait, but this could be changed. There are a few options here that we could take:Poly
. This means that every type can be logged via{}
by default, although some output may not be as expected. This also means it's not overridable.T: ToStr
. This would basically callto_str()
on the argument, and it would fail if you don't ascribe to theToStr
trait. The downside of this is that if you implementToStr
you can't override your default formatting representation.fmt::Default
trait. All the basic types would implement this with their respective formats. This could possibly remove the need for thes
,d
,u
,i
,c
, andp
traits, but that may need to be a separate issue.I think the current default of
Poly
is probably a bad idea, and I'm starting to lean towards theDefault
trait. I think that for formatting specifiers (like{:.10s}
) we would want to keep the other formats, but this means that any type could implementDefault
however it pleases. It also means that 99% of the formats done today could just be a dead-simple{}
(although that's just a guess).One note on performance, anything implementing the
Default
may not have to worry about format specifiers/flags/etc because the format specifier grammar wouldn't allow specifying these flags without specifying a format string (likes
ord
), and there's no reason that a format string forDefault
has to be defined... That's kinda a side note though.Nominating for the backwards compatibility milestone as well (especially because the default is
?
today.The text was updated successfully, but these errors were encountered: