-
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 using push_str with a single-character string literal, and push with a char would work fine.
Categories (optional)
- Kind:
clippy::styleandclippy::perf(maybeclippy::pedantic?)
What is the advantage of the recommended code over the original code?
- It's more obvious what's going on; after all, you're not trying to push a string, you're trying to push a character
- It should be more performant and reduce binary size to push a
char, since it's just a number and will be inlined, than to push a&'static str, which must be stored in the binary and accessed via a pointer
Drawbacks
None.
Example
let mut string = String::new();
string.push_str("R");Could be written as:
let mut string = String::new();
string.push('R');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