3 At the end of the day, everything is just a pile of bits somewhere, and type
4 systems are just there to help us use those bits right. There are two common
5 problems with typing bits: needing to reinterpret those exact bits as a
6 different type, and needing to change the bits to have equivalent meaning for
7 a different type. Because Rust encourages encoding important properties in the
8 type system, these problems are incredibly pervasive. As such, Rust
9 consequently gives you several ways to solve them.
11 First we'll look at the ways that *Safe Rust* gives you to reinterpret values.
12 The most trivial way to do this is to just destructure a value into its
13 constituent parts and then build a new type out of them. e.g.
26 fn reinterpret(foo: Foo) -> Bar {
27 let Foo { x, y } = foo;
32 But this is, at best, annoying. For common conversions, Rust provides
33 more ergonomic alternatives.