]> git.lizzy.rs Git - rust.git/blob - src/docs/manual_swap.txt
Add iter_kv_map lint
[rust.git] / src / docs / manual_swap.txt
1 ### What it does
2 Checks for manual swapping.
3
4 ### Why is this bad?
5 The `std::mem::swap` function exposes the intent better
6 without deinitializing or copying either variable.
7
8 ### Example
9 ```
10 let mut a = 42;
11 let mut b = 1337;
12
13 let t = b;
14 b = a;
15 a = t;
16 ```
17 Use std::mem::swap():
18 ```
19 let mut a = 1;
20 let mut b = 2;
21 std::mem::swap(&mut a, &mut b);
22 ```