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);
}
A tuple is like a fixed-size box that holds a specific set of different items together. You use it when you need to return multiple values from a function or group related data without defining a custom structure. Think of it as a single package containing a name, an age, and a score that always travel together.