Skip to content

useless_format should only warn for String #697

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

Closed
Manishearth opened this issue Feb 22, 2016 · 5 comments
Closed

useless_format should only warn for String #697

Manishearth opened this issue Feb 22, 2016 · 5 comments

Comments

@Manishearth
Copy link
Member

It currently warns for format!("{}", e); where e is anything implementing Show.

cc @mcarton

@oli-obk
Copy link
Contributor

oli-obk commented Feb 22, 2016

The warning is correct imo, e.to_string() is much more obvious. So only the hint should be adjusted.

@mcarton
Copy link
Member

mcarton commented Feb 22, 2016

Show hasn’t been a thing for a long time now (in Rust history) :p

I that case I like e.to_string() better, no?

@Manishearth
Copy link
Member Author

Using format in lieu of .to_string() is a common pattern, though.

@mcarton
Copy link
Member

mcarton commented Feb 22, 2016

They are equivalent anyway as the trait implementation is impl<T> ToString for T where T: Display + ?Sized so ok, I’ll limit it to String and &str.

@llogiq
Copy link
Contributor

llogiq commented Feb 22, 2016

I still think .to_string() is more readable. Maybe re-add it as an allowed lint?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants