Rollup merge of #111168 - DaniPopes:arguments-to-string, r=Mark-Simulacrum
Specialize ToString implementation for fmt::Arguments Generates far fewer instructions by formatting into a String with `fmt::format` directly instead of going through the `fmt::Display` impl. This change is insta-stable.
This commit is contained in:
commit
e0991b7bcd
@ -2623,6 +2623,15 @@ impl ToString for String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(no_global_oom_handling))]
|
||||||
|
#[stable(feature = "fmt_arguments_to_string_specialization", since = "CURRENT_RUSTC_VERSION")]
|
||||||
|
impl ToString for fmt::Arguments<'_> {
|
||||||
|
#[inline]
|
||||||
|
fn to_string(&self) -> String {
|
||||||
|
crate::fmt::format(*self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl AsRef<str> for String {
|
impl AsRef<str> for String {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user