rust-lang / rust-lang/rust-clippy
Suggest using Cow on mixture of &'static str + Strings
Open
@llogiq is already working on this.
Since Sep 15, 2015.
A-lint
E-hard
T-middle
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
I see a lot of owned strings in many places where a Cow<'static, str> will do. The latter will likely improve performance.
How do we detect this? It's a value of type String which are only initialized with other Strings from elsewhere or &'static str (via .to_owned()/.to_string()). Also we should probably check if the value is part of the public interface (as we did recently with wrong_pub_self_convention).
I think this should be possible with the ExprUseVisitor – so I finally have a reason to check it out. 😄
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.