rust-lang / rust-lang/rust-clippy
new lint for &str to String conversion
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
There are a few different ways to convert from a &str to a String:
fn main() {
let _: String = "hello".to_owned();
let _: String = "hello".to_string();
let _: String = "hello".into();
let _: String = String::from("hello");
let _: String = format!("hello");
}
Without going into a discussion about which is the best (this lint has been deprecated), I think a lint to ensure the same one is used throughout a crate would be interesting.
This could be done either through configuration, or by keeping stats on which is used and then emit warning for the non majority one.
I can work on it, but wanted to have a general point of view before. What do you think ?
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.
Research direction
Start with the issue's four Rust conversion examples and review the deprecated str_to_string lint linked in the description. Resolve whether the lint should use explicit configuration or infer the crate's majority style, then define how non-majority conversions are identified and what behavior marks the work complete.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100