-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
A-lintArea: New lintsArea: New lintsC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
What it does
Warns when turning a char
into a String
before pushing it to another String
.
Advantage
- It's more clear that we're pushing only a single
char
- It doesn't allocate a new
String
Drawbacks
No response
Example
let mut s = String::from("...");
let c = 'a';
// or: let c = &'a';
s.push_str(&c.to_string());
// or: s = s + &c.to_string();
// or: s += &c.to_string();
Could be written as:
let mut s = String::from("...");
let c = 'a';
s.push(c);
// or: s.push(*c); for the reference case
paolobarbolini
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lintsC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy