Rust - Tuple Flashcards
1
Q
Describe Tuple
A
Tuple is a compound data type.
It can store different data types.
It has a fixed length; once decleared it cannot grow or shrink in size
2
Q
An example of a tuple and print it
A
let personal_info : (String, u32, u64) = (String::from(“Ibekwe Prince”), 19, 177);
println!(Name: {:?}, personal_info.0)
3
Q
Pass a tuple as a parameter to a function
A
let b : (i32, bool, f64) = (110, true, 10.9);
print(b);
fn print(tup: (i32, bool, f64)){
//
}
4
Q
How to destruct a tupe.
A
let b:(i32,bool,f64) = (30,true,7.9);
let (age, is_male, cg)