1- error: use `Option::as_slice`
1+ error: manual implementation of `Option::as_slice`
22 --> tests/ui/manual_option_as_slice.rs:5:9
33 |
44LL | _ = match x.as_ref() {
77LL | | Some(f) => std::slice::from_ref(f),
88LL | | None => &[],
99LL | | };
10- | |_____^ help: use: `x.as_slice()`
10+ | |_____^
1111 |
1212 = note: `-D clippy::manual-option-as-slice` implied by `-D warnings`
1313 = help: to override `-D warnings` add `#[allow(clippy::manual_option_as_slice)]`
14+ help: use `Option::as_slice` directly
15+ |
16+ LL - _ = match x.as_ref() {
17+ LL -
18+ LL - Some(f) => std::slice::from_ref(f),
19+ LL - None => &[],
20+ LL - };
21+ LL + _ = x.as_slice();
22+ |
1423
15- error: use `Option::as_slice`
24+ error: manual implementation of `Option::as_slice`
1625 --> tests/ui/manual_option_as_slice.rs:11:9
1726 |
1827LL | _ = if let Some(f) = x.as_ref() {
@@ -23,37 +32,79 @@ LL | | std::slice::from_ref(f)
2332LL | | } else {
2433LL | | &[]
2534LL | | };
26- | |_____^ help: use: `x.as_slice()`
35+ | |_____^
36+ |
37+ help: use `Option::as_slice` directly
38+ |
39+ LL - _ = if let Some(f) = x.as_ref() {
40+ LL -
41+ LL -
42+ LL - std::slice::from_ref(f)
43+ LL - } else {
44+ LL - &[]
45+ LL - };
46+ LL + _ = x.as_slice();
47+ |
2748
28- error: use `Option::as_slice`
49+ error: manual implementation of `Option::as_slice`
2950 --> tests/ui/manual_option_as_slice.rs:19:9
3051 |
3152LL | _ = x.as_ref().map_or(&[][..], std::slice::from_ref);
32- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `x.as_slice()`
53+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
54+ |
55+ help: use `Option::as_slice` directly
56+ |
57+ LL - _ = x.as_ref().map_or(&[][..], std::slice::from_ref);
58+ LL + _ = x.as_slice();
59+ |
3360
34- error: use `Option::as_slice`
61+ error: manual implementation of `Option::as_slice`
3562 --> tests/ui/manual_option_as_slice.rs:22:9
3663 |
3764LL | _ = x.as_ref().map_or_else(Default::default, std::slice::from_ref);
38- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `x.as_slice()`
65+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66+ |
67+ help: use `Option::as_slice` directly
68+ |
69+ LL - _ = x.as_ref().map_or_else(Default::default, std::slice::from_ref);
70+ LL + _ = x.as_slice();
71+ |
3972
40- error: use `Option::as_slice`
73+ error: manual implementation of `Option::as_slice`
4174 --> tests/ui/manual_option_as_slice.rs:25:9
4275 |
4376LL | _ = x.as_ref().map(std::slice::from_ref).unwrap_or_default();
44- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `x.as_slice()`
77+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
78+ |
79+ help: use `Option::as_slice` directly
80+ |
81+ LL - _ = x.as_ref().map(std::slice::from_ref).unwrap_or_default();
82+ LL + _ = x.as_slice();
83+ |
4584
46- error: use `Option::as_slice`
85+ error: manual implementation of `Option::as_slice`
4786 --> tests/ui/manual_option_as_slice.rs:28:9
4887 |
4988LL | _ = x.as_ref().map_or_else(|| &[42][..0], std::slice::from_ref);
50- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `x.as_slice()`
89+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
90+ |
91+ help: use `Option::as_slice` directly
92+ |
93+ LL - _ = x.as_ref().map_or_else(|| &[42][..0], std::slice::from_ref);
94+ LL + _ = x.as_slice();
95+ |
5196
52- error: use `Option::as_slice`
97+ error: manual implementation of `Option::as_slice`
5398 --> tests/ui/manual_option_as_slice.rs:33:13
5499 |
55100LL | _ = x.as_ref().map_or_else(<&[_]>::default, from_ref);
56- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `x.as_slice()`
101+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
102+ |
103+ help: use `Option::as_slice` directly
104+ |
105+ LL - _ = x.as_ref().map_or_else(<&[_]>::default, from_ref);
106+ LL + _ = x.as_slice();
107+ |
57108
58109error: aborting due to 7 previous errors
59110
0 commit comments