Description
Arguments::as_str
allows code to handle argument-less fmt::Arguments
like format_args!("literal")
specially by not pulling in any formatting code.
We should investigate if we can improve format_args!("hello: {}", "literal")
to result in the same trivial fmt::Arguments
as format_args!("hello: literal")
, such that any .as_str()
-based optimizations are also available for it.
That could also make things like panic!("{}", "message");
work with const_panic
, removing the need for panic!(CONST_STR)
.
This makes panic!("hello")
exactly as cheap (and const) as panic!("{}", "hello")
, which is also important for #78088 to make sure there are no downsides to its suggestions.
It'd also reduce the need for using concat!(..)
, since it'd no longer be less efficient to add a {}
placeholder to concat literals in a formatting string instead.
As a bonus: format_args!("a: {}", format_args!("b: {}", ..))
could maybe also improved to produce the same as format_args!("a: b: {}", ..)
.
Assigning to myself to investigate some time Soon™.