mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-03-23 15:14:35 +02:00
Update from-into.md (#245)
Explaining how those traits are used in practice and when you should use one over another.
This commit is contained in:
parent
12c3e2989d
commit
05cc2ff480
@ -23,3 +23,11 @@ fn main() {
|
|||||||
println!("{s}, {addr}, {one}, {bigger}");
|
println!("{s}, {addr}, {one}, {bigger}");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
* That's why it is common to only implement `From`, as your type will get `Into` implementation too.
|
||||||
|
* When declaring a function argument input type like "anything that can be converted into a `String`", the rule is opposite, you should use `Into`.
|
||||||
|
Your function will accept types that implement `From` and those that _only_ implement `Into`.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user