Get Values Out Of A Tuple In Rust
This is how to access the values of a rust tuple directly
fn main() {
let characters: (char, char, char) = ('a', 'b', 'c');
println!("The second character is: {}", characters.1)
}
Output:
The second character is: b
Destructuring
And this is how to do it with destructuring
fn main() {
let numbers: (i32, f64, i32) = (500, 6.4, 1);
let (x, y, z) = numbers;
println!("The value of y is: {}", y);
}
Output:
The value of y is: 6.4
-- end of line --