home
NOTE: Under Construction - I'm in the middle of upgrading my site and lots of stuff is kinda broken. Please forgive the mess.

Get Values Out Of A Tuple In Rust

April 2021

This is how to access the values of a rust tuple directly

Code
fn main() {
      let characters: (char, char, char) = ('a', 'b', 'c');

      println!("The second character is: {}", characters.1)
  }
Results
The second character is: b

*** Destructuring

And this is how to do it with destructuring

Code
fn main() {
      let numbers: (i32, f64, i32) = (500, 6.4, 1);

      let (x, y, z) = numbers;

      println!("The value of y is: {}", y);
  }
Results
The value of y is: 6.4
═══ § ═══