You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Warn that .to_string() is only required once. Even with pedantic clippy this doesn't give any warning.
Advantage
It can happen to anyone if you process a lot of code that you accidently call .to_string() more then once on a variable. It takes up useless characters in your file and looks sloppy. This looks like something clippy could fix automatically with the --fix argument.
Drawbacks
I can't think of any since I don't know any situation where it would make sense to call .to_string() twice in a variable.
Example
let uri = req.uri().path().to_string().to_string();
Could be written as:
let uri = req.uri().path().to_string();
The text was updated successfully, but these errors were encountered:
warning: redundant clone
--> src/main.rs:6:9
|
6 | .to_string()
| ^^^^^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> src/main.rs:4:5
|
4 | / x
5 | | .to_string()
6 | | .to_string()
| |________^
What it does
Warn that
.to_string()
is only required once. Even with pedantic clippy this doesn't give any warning.Advantage
It can happen to anyone if you process a lot of code that you accidently call
.to_string()
more then once on a variable. It takes up useless characters in your file and looks sloppy. This looks like something clippy could fix automatically with the--fix
argument.Drawbacks
I can't think of any since I don't know any situation where it would make sense to call
.to_string()
twice in a variable.Example
Could be written as:
The text was updated successfully, but these errors were encountered: