Add examples to some correctness lints

This commit is contained in:
BO41 2019-08-18 21:37:47 +02:00
parent 6d9ee9e5eb
commit 43a2ba34e6
2 changed files with 10 additions and 0 deletions

View File

@ -889,6 +889,10 @@ declare_clippy_lint! {
/// ```rust
/// let _ = [1, 2, 3].into_iter().map(|x| *x).collect::<Vec<u32>>();
/// ```
/// Could be written as:
/// ```rust
/// let _ = [1, 2, 3].iter().map(|x| *x).collect::<Vec<u32>>();
/// ```
pub INTO_ITER_ON_ARRAY,
correctness,
"using `.into_iter()` on an array"

View File

@ -52,6 +52,12 @@ declare_clippy_lint! {
/// a = b;
/// b = a;
/// ```
/// Could be written as:
/// ```rust
/// # let mut a = 1;
/// # let mut b = 2;
/// std::mem::swap(&mut a, &mut b);
/// ```
pub ALMOST_SWAPPED,
correctness,
"`foo = bar; bar = foo` sequence"