]> git.lizzy.rs Git - rust.git/blob - src/docs/almost_swapped.txt
[Arithmetic] Consider literals
[rust.git] / src / docs / almost_swapped.txt
1 ### What it does
2 Checks for `foo = bar; bar = foo` sequences.
3
4 ### Why is this bad?
5 This looks like a failed attempt to swap.
6
7 ### Example
8 ```
9 a = b;
10 b = a;
11 ```
12 If swapping is intended, use `swap()` instead:
13 ```
14 std::mem::swap(&mut a, &mut b);
15 ```