How to swap two variables in Rust?
In Rust it's simple to swap variables values check Example below:fn main() {
let (a, b) = (1, 2);
let (a, b) = (b, a);
println!("Value of a = {}, value of b = {} ", a, b);
}
Output
Value of a = 2, value of b = 1