Swap Values
Write a function called swap that takes mutable borrows of two i32 values and swaps them. Print before and after to show the swap worked.
Expected output:
text
Before: a=10, b=20 After: a=20, b=10
Hints:
- Function signature:
fn swap(a: &mut i32, b: &mut i32) - Use a temporary variable:
let temp = *a; - Use
*aand*bto read/write the values behind the references
rust
fn main() {
}