]> git.lizzy.rs Git - rust.git/blob - src/docs/str_to_string.txt
Auto merge of #9425 - kraktus:patch-1, r=xFrednet
[rust.git] / src / docs / str_to_string.txt
1 ### What it does
2 This lint checks for `.to_string()` method calls on values of type `&str`.
3
4 ### Why is this bad?
5 The `to_string` method is also used on other types to convert them to a string.
6 When called on a `&str` it turns the `&str` into the owned variant `String`, which can be better
7 expressed with `.to_owned()`.
8
9 ### Example
10 ```
11 // example code where clippy issues a warning
12 let _ = "str".to_string();
13 ```
14 Use instead:
15 ```
16 // example code which does not raise clippy warning
17 let _ = "str".to_owned();
18 ```