How to Do Type Casting in Rust with as

Use the `as` keyword to convert primitive types in Rust, such as casting an i32 to a u8.

Use the as keyword to cast a value from one primitive type to another by placing the target type after the keyword. This operation performs a truncation or conversion based on the size of the target type.

fn main() {
    let x: i32 = 42;
    let y: u8 = x as u8;
    println!("{y}");
}