Skip to content
New issue

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

Suggest use to_string rather than format!("{}") #8828

Open
leiysky opened this issue May 13, 2022 · 3 comments
Open

Suggest use to_string rather than format!("{}") #8828

leiysky opened this issue May 13, 2022 · 3 comments
Labels
A-lint Area: New lints

Comments

@leiysky
Copy link

leiysky commented May 13, 2022

What it does

Sometime, people are using format!("{}") to stringify an object, which can be rewritten in .to_string() to keep code clean.

Lint Name

No response

Category

style

Advantage

No response

Drawbacks

No response

Example

let a = format!("{}", x);

Could be written as:

let a = x.to_string();
@leiysky leiysky added the A-lint Area: New lints label May 13, 2022
@smoelius
Copy link
Contributor

Could it be this already exists? https://rust-lang.github.io/rust-clippy/master/#useless_format

@andylokandy
Copy link

useless_format only take effect if foo is a string, but it should be any type that implemented Display.

@smoelius
Copy link
Contributor

LOL #697

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

No branches or pull requests

3 participants