Skip to content

Commit 43a2ba3

Browse files
author
BO41
committed
Add examples to some correctness lints
1 parent 6d9ee9e commit 43a2ba3

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

clippy_lints/src/methods/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,10 @@ declare_clippy_lint! {
889889
/// ```rust
890890
/// let _ = [1, 2, 3].into_iter().map(|x| *x).collect::<Vec<u32>>();
891891
/// ```
892+
/// Could be written as:
893+
/// ```rust
894+
/// let _ = [1, 2, 3].iter().map(|x| *x).collect::<Vec<u32>>();
895+
/// ```
892896
pub INTO_ITER_ON_ARRAY,
893897
correctness,
894898
"using `.into_iter()` on an array"

clippy_lints/src/swap.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ declare_clippy_lint! {
5252
/// a = b;
5353
/// b = a;
5454
/// ```
55+
/// Could be written as:
56+
/// ```rust
57+
/// # let mut a = 1;
58+
/// # let mut b = 2;
59+
/// std::mem::swap(&mut a, &mut b);
60+
/// ```
5561
pub ALMOST_SWAPPED,
5662
correctness,
5763
"`foo = bar; bar = foo` sequence"

0 commit comments

Comments
 (0)