Description
When using ifmt
, a format argument can be simple as {}
which means "the next argument" formatted as "the default". Currently the default is the ?
or fmt::Poly
format trait, but this could be changed. There are a few options here that we could take:
- Stick with
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. - Define default for
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. - Create an entirely new
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 the Default
trait. I think that for formatting specifiers (like {:.10s}
) we would want to keep the other formats, but this means that any type could implement Default
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 (like s
or d
), and there's no reason that a format string for Default
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.