Casting explicitly turns a value into another compatible type. In Rust, use `as` followed by the target type. This is useful because Rust treats different types as distinct, even when both are integers. section 1.3
A `u8` is an integer from 0 to 255 and can be cast to a `char`. An `i32` cannot be cast directly to `char`: the compiler reports an error. Cast it to `u8` first, then to `char`. section 1.3
fn main() {
let my_number = 100;
println!("{}", my_number as u8 as char);
}
The two casts turn 100 into a `u8` and then a `char`. The program prints `d`, the character at number 100. section 1.3
Watch out for smaller types
Casting a large number to a smaller type can change its value. For example, `256 as u8` produces 0, not 255. section 1.3





















