Skip to content

Commit

Permalink
Explain why inline default ToString impl
Browse files Browse the repository at this point in the history
  • Loading branch information
tesuji committed Jul 29, 2020
1 parent 4cca950 commit 27e1b06
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2196,6 +2196,9 @@ pub trait ToString {
/// since `fmt::Write for String` never returns an error itself.
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: fmt::Display + ?Sized> ToString for T {
// A common guideline is to not inline generic functions. However,
// remove `#[inline]` from this method causes non-negligible regression.
// See <https://github.com/rust-lang/rust/pull/74852> as last attempt try to remove it.
#[inline]
default fn to_string(&self) -> String {
use fmt::Write;
Expand Down

0 comments on commit 27e1b06

Please sign in to comment.