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

### Why is this bad?
The `to_string` method is also used on other types to convert them to a string.
When called on a `&str` it turns the `&str` into the owned variant `String`, which can be better
expressed with `.to_owned()`.

### Example
```
// example code where clippy issues a warning
let _ = "str".to_string();
```
Use instead:
```
// example code which does not raise clippy warning
let _ = "str".to_owned();
```