Skip to content

Commit 27e1b06

Browse files
committed
Explain why inline default ToString impl
1 parent 4cca950 commit 27e1b06

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

library/alloc/src/string.rs

+3
Original file line numberDiff line numberDiff line change
@@ -2196,6 +2196,9 @@ pub trait ToString {
21962196
/// since `fmt::Write for String` never returns an error itself.
21972197
#[stable(feature = "rust1", since = "1.0.0")]
21982198
impl<T: fmt::Display + ?Sized> ToString for T {
2199+
// A common guideline is to not inline generic functions. However,
2200+
// remove `#[inline]` from this method causes non-negligible regression.
2201+
// See <https://github.com/rust-lang/rust/pull/74852> as last attempt try to remove it.
21992202
#[inline]
22002203
default fn to_string(&self) -> String {
22012204
use fmt::Write;

0 commit comments

Comments
 (0)