]> git.proxmox.com Git - rustc.git/blob - src/doc/rust-by-example/src/conversion.md
New upstream version 1.44.1+dfsg1
[rustc.git] / src / doc / rust-by-example / src / conversion.md
1 # Conversion
2
3 Primitive types can be converted to each other through [casting].
4
5 Rust addresses conversion between custom types (i.e., `struct` and `enum`)
6 by the use of [traits]. The generic
7 conversions will use the [`From`] and [`Into`] traits. However there are more
8 specific ones for the more common cases, in particular when converting to and
9 from `String`s.
10
11 [casting]: types/cast.md
12 [traits]: trait.md
13 [`From`]: https://doc.rust-lang.org/std/convert/trait.From.html
14 [`Into`]: https://doc.rust-lang.org/std/convert/trait.Into.html