元组的使用
fn main() {
let my_tuple : (i32, &str, f64) = (10, "hello", 3.14);
println!("{:?}", my_tuple);
let first_element = my_tuple.0;
let second_element = my_tuple.1;
let third_element = my_tuple.2;
println!("First element: {}", first_element);
println!("Second element: {}", second_element);
println!("Third element: {}", third_element);
let (a, b, c) = my_tuple;
println!("a: {}, b: {}, c: {}", a, b, c);
fn get_coordinates() -> (i32, i32) {
(3, 7)
}
let (x, y) = get_coordinates();
println!("x: {}, y: {}", x, y);
}
输出结果