]> git.lizzy.rs Git - rust.git/blob - src/docs/from_over_into.txt
Add iter_kv_map lint
[rust.git] / src / docs / from_over_into.txt
1 ### What it does
2 Searches for implementations of the `Into<..>` trait and suggests to implement `From<..>` instead.
3
4 ### Why is this bad?
5 According the std docs implementing `From<..>` is preferred since it gives you `Into<..>` for free where the reverse isn't true.
6
7 ### Example
8 ```
9 struct StringWrapper(String);
10
11 impl Into<StringWrapper> for String {
12     fn into(self) -> StringWrapper {
13         StringWrapper(self)
14     }
15 }
16 ```
17 Use instead:
18 ```
19 struct StringWrapper(String);
20
21 impl From<String> for StringWrapper {
22     fn from(s: String) -> StringWrapper {
23         StringWrapper(s)
24     }
25 }
26 ```