File tree 6 files changed +23
-8
lines changed
6 files changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ declare_clippy_lint! {
29
29
/// ```
30
30
/// Could be written as:
31
31
/// ```rust
32
- /// fn foo() {}
32
+ /// fn foo<T> () {}
33
33
/// ```
34
34
pub DROP_BOUNDS ,
35
35
correctness,
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ declare_clippy_lint! {
30
30
/// xs.map(|x| foo(x))
31
31
///
32
32
/// // Good
33
- /// foo(xs )
33
+ /// xs.map(foo )
34
34
/// ```
35
35
/// where `foo(_)` is a plain function that takes the exact argument type of
36
36
/// `x`.
Original file line number Diff line number Diff line change @@ -30,8 +30,11 @@ declare_clippy_lint! {
30
30
/// // Unclear whether a is 1 or 2.
31
31
///
32
32
/// // Good
33
- /// x = 1;
34
- /// let a = 1 + x;
33
+ /// let tmp = {
34
+ /// x = 1;
35
+ /// 1
36
+ /// };
37
+ /// let a = tmp + x;
35
38
/// ```
36
39
pub EVAL_ORDER_DEPENDENCE ,
37
40
complexity,
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ declare_clippy_lint! {
18
18
/// **Known problems:** None.
19
19
///
20
20
/// **Example:**
21
- /// ```rust,ignore
21
+ /// ```rust
22
22
/// struct Foo(i32);
23
23
///
24
24
/// // Bad
@@ -27,13 +27,21 @@ declare_clippy_lint! {
27
27
/// Foo(s.parse().unwrap())
28
28
/// }
29
29
/// }
30
+ /// ```
30
31
///
32
+ /// ```rust
31
33
/// // Good
34
+ /// struct Foo(i32);
35
+ ///
32
36
/// use std::convert::TryFrom;
33
37
/// impl TryFrom<String> for Foo {
34
38
/// type Error = ();
35
39
/// fn try_from(s: String) -> Result<Self, Self::Error> {
36
- /// s.parse()
40
+ /// if let Ok(parsed) = s.parse() {
41
+ /// Ok(Foo(parsed))
42
+ /// } else {
43
+ /// Err(())
44
+ /// }
37
45
/// }
38
46
/// }
39
47
/// ```
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ declare_clippy_lint! {
52
52
/// ```rust
53
53
/// fn im_too_long() {
54
54
/// println!("");
55
- /// // ... 100 more LoC
55
+ /// // ... 100 more LoC
56
56
/// println!("");
57
57
/// }
58
58
/// ```
Original file line number Diff line number Diff line change @@ -436,7 +436,11 @@ declare_clippy_lint! {
436
436
/// vec.iter().filter(|x| **x == 0).map(|x| *x * 2);
437
437
///
438
438
/// // Good
439
- /// vec.iter().filter_map(|x| Some(*x * 2));
439
+ /// vec.iter().filter_map(|x| if *x == 0 {
440
+ /// Some(*x * 2)
441
+ /// } else {
442
+ /// None
443
+ /// });
440
444
/// ```
441
445
pub FILTER_MAP ,
442
446
pedantic,
You can’t perform that action at this time.
0 commit comments