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
How about into() or String::from()? One advantage of such conversion is that it keeps working when the type changes a bit. Also useful for Box<str>.
Also why only temporary? I think doing the same when the cow is no longer used even when it's bound should be doable. (I realize this is kinda reimplementing part of borrow checking, but I hope it's simple enough.)
In general any conversion of Cow<'_, Foo> into Foo::Owned when the original value is not used later should be linted.
What it does
The lint is meant to detect calling
.to_string()
on a temporaryCow<'_, str>
.This is not a rare case when a beginner makes such a mistake.
Categories (optional)
clippy::perf
What is the advantage of the recommended code over the original code:
Cow<'_, str>
.Drawbacks
None.
Example
Could be written as:
The text was updated successfully, but these errors were encountered: