Macro aoko::swap_mut[][src]

macro_rules! swap_mut {
    ($($a : ident, $b : ident) ; * $(;) ?) => { ... };
}
Expand description

Swaps two variables’ value.

Principles

Shadowing by two mutable variables.

Examples

use aoko::swap_mut;
 
let (a, b, c, d) = (1, 2, 3, 4);
swap_mut!(a, b; c, d;);
assert_eq!((a, b, c, d), (2, 1, 4, 3));
 
a = 10; b = 20; c = 30; d = 40;
assert_eq!((a, b, c, d), (10, 20, 30, 40));