We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detects the use of format!() and .to_string() in arguments to a function expecting impl fmt::Display.
format!()
.to_string()
impl fmt::Display
(Possible duplicate of #3021, #3156)
useless_format
perf, pedantic
fn foo(_: impl std::fmt::Display) {} foo("xyz".to_string()); foo(format!("{} {}", 1, 2));
Could be written as:
fn foo(_: impl std::fmt::Display) {} foo("xyz"); foo(format_args!("{} {}", 1, 2));
The text was updated successfully, but these errors were encountered:
For .to_string(), this could be an enhancement of unnecessary_to_owned.
unnecessary_to_owned
I'm not sure about suggesting format_args! because if it is used multiple times there could be a negative perf impact.
format_args!
Sorry, something went wrong.
@rustbot claim
No branches or pull requests
What it does
Detects the use of
format!()
and.to_string()
in arguments to a function expectingimpl fmt::Display
.(Possible duplicate of #3021, #3156)
Lint Name
useless_format
Category
perf, pedantic
Advantage
Drawbacks
Example
Could be written as:
The text was updated successfully, but these errors were encountered: