summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/string_to_string.txt
blob: deb7eebe7842c5177dffd094e61b5befdd861dac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
### What it does
This lint checks for `.to_string()` method calls on values of type `String`.

### Why is this bad?
The `to_string` method is also used on other types to convert them to a string.
When called on a `String` it only clones the `String`, which can be better expressed with `.clone()`.

### Example
```
// example code where clippy issues a warning
let msg = String::from("Hello World");
let _ = msg.to_string();
```
Use instead:
```
// example code which does not raise clippy warning
let msg = String::from("Hello World");
let _ = msg.clone();
```