Skip to content

Commit

Permalink
Auto merge of #77997 - fusion-engineering-forks:to-string-no-shrink, …
Browse files Browse the repository at this point in the history
…r=joshtriplett

Remove shrink_to_fit from default ToString::to_string implementation.

As suggested by `@scottmcm` on Zulip. shrink_to_fit() seems like the wrong thing to do here in most use cases of to_string(). Would be intereseting to see if it makes any difference in a timer run.

r? `@joshtriplett`
  • Loading branch information
bors committed Oct 16, 2020
2 parents e3051d8 + 0b06288 commit f1b97ee
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2200,7 +2200,6 @@ impl<T: fmt::Display + ?Sized> ToString for T {
let mut buf = String::new();
buf.write_fmt(format_args!("{}", self))
.expect("a Display implementation returned an error unexpectedly");
buf.shrink_to_fit();
buf
}
}
Expand Down

0 comments on commit f1b97ee

Please sign in to comment.