How to Use Tuples in Rust

Group fixed, heterogeneous values in Rust using parentheses and access them via destructuring or index notation.

Use tuples to group fixed numbers of values with potentially different types by enclosing them in parentheses and separating them with commas.

fn main() {
    let tup: (i32, f64, u8) = (500, 6.4, 1);
    let (x, y, z) = tup;
    println!("{x}, {y}, {z}");
    println!("{:.1}", tup.1);
}