Skip to content

Commit 05cc2ff

Browse files
authored
Update from-into.md (#245)
Explaining how those traits are used in practice and when you should use one over another.
1 parent 12c3e29 commit 05cc2ff

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/traits/from-into.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@ fn main() {
2323
println!("{s}, {addr}, {one}, {bigger}");
2424
}
2525
```
26+
27+
<details>
28+
29+
* That's why it is common to only implement `From`, as your type will get `Into` implementation too.
30+
* When declaring a function argument input type like "anything that can be converted into a `String`", the rule is opposite, you should use `Into`.
31+
Your function will accept types that implement `From` and those that _only_ implement `Into`.
32+
33+
</details>

0 commit comments

Comments
 (0)