You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was randomly looking at another PR, and noticed that in about
half the cases, we heap allocate a `String`, but then use `as_str()`
to borrow it briefly. In other places we directly use `&str`.
It maximizes flexibility for the caller to use `AsRef<str>`; then
we don't need a `.as_str()` dance, we can just directly pass ownership
of the string into the function.
To pick one other random real world example of this, see:
https://github.com/rust-lang/rust/blob/9bb77da74dac4768489127d21e32db19b59ada5b/compiler/rustc_errors/src/diagnostic_builder.rs#L198
Signed-off-by: Colin Walters <[email protected]>
0 commit comments