published: 13th of February 2022
A tuple is a sequence of values, which can be of different types. A tuple is defined with circle brackets () .
// Create a tuple with 3 elements.
let stuff = ("stuff", 42, 'a');
// Annotate the types of the tuple values.
let things: (&str, u8, char) = ("things", 69, 'z');
// Tuple elements are accessed with the dot '(.)' operator
// and their 'index' number.
println!("{}", stuff.0); // => stuff
println!("{}", things.1); // => 69
// All the elements of a tuple can be destructured into a pattern.
let (a, b, c) = stuff;
https://www.manning.com/books/rust-in-action
https://www.udemy.com/course/ultimate-rust-crash-course/
https://doc.rust-lang.org/std/primitive.tuple.html
https://doc.rust-lang.org/book/ch03-02-data-types.html#the-tuple-type