Return multiple values from a function
examples/tuples/return-multiple-values/src/main.rs
fn main() { let (sum, diff) = calc(10, 5); println!("sum: {sum} diff: {diff}"); } fn calc(a: i32, b: i32) -> (i32, i32) { (a + b, a - b) }
sum: 15 diff: 5
fn main() { let (sum, diff) = calc(10, 5); println!("sum: {sum} diff: {diff}"); } fn calc(a: i32, b: i32) -> (i32, i32) { (a + b, a - b) }
sum: 15 diff: 5