almost_swapped
code:text
What it does
Checks for foo = bar; bar = foo sequences.
Why is this bad?
This looks like a failed attempt to swap.
Example
a = b;
b = a;
If swapping is intended, use swap() instead:
std::mem::swap(&mut a, &mut b);
メモ
code:error message
error: this looks like you are trying to swap x and y
--> src/main.rs:5:5
|
5 | / x = y;
6 | | y = x;
| |_________^ help: try: std::mem::swap(&mut x, &mut y)
|
= note: #[deny(clippy::almost_swapped)] on by default
= note: or maybe you should use std::mem::replace?
warning: playground (bin "playground") generated 2 warnings
error: could not compile playground due to previous error; 2 warnings emitted
std::mem::swap と std::mem::replace が触れられているので両者の違いについて調べてもいいかもしれない。
let だとこの怒られが発生しない、というIssueが立っていた。Krouton.icon的には意図通りだと思うのだがどうなのだろう・・・。