3.3 Tuples
- Similar types include arrays and slices, but they are not commonly used in rust, and Vector is commonly used
tuple
- Store data anonymously
- Immutable
The usefulness of tuples
- function return
- extract variables
the code
fn a_tuple() -> (i32, i32) {
(0, 1)
}
fn main() {
println!("{:?}", a_tuple());
let (a, b) = a_tuple();
println!("a: {}, b: {}", a, b);
}