Closed
Description
What it does
The lint is meant to detect calling .to_string()
on a temporary Cow<'_, str>
.
This is not a rare case when a beginner makes such a mistake.
Categories (optional)
- Kind:
clippy::perf
What is the advantage of the recommended code over the original code:
- Avoid wasting a potentially owned string inside of the temporary
Cow<'_, str>
.
Drawbacks
None.
Example
let path_str: String = path.to_string_lossy().to_string();
Could be written as:
let path_str: String = path.to_string_lossy().into_owned();