]>
git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/search_is_some_fixable.rs
3 #![warn(clippy::search_is_some)]
6 let v
= vec
![3, 2, 1, 0, -1, -2, -3];
9 // Check `find().is_some()`, single-line case.
10 let _
= v
.iter().find(|&x
| *x
< 0).is_some();
11 let _
= (0..1).find(|x
| **y
== *x
).is_some(); // one dereference less
12 let _
= (0..1).find(|x
| *x
== 0).is_some();
13 let _
= v
.iter().find(|x
| **x
== 0).is_some();
15 // Check `position().is_some()`, single-line case.
16 let _
= v
.iter().position(|&x
| x
< 0).is_some();
18 // Check `rposition().is_some()`, single-line case.
19 let _
= v
.iter().rposition(|&x
| x
< 0).is_some();
21 let s1
= String
::from("hello world");
22 let s2
= String
::from("world");
23 // caller of `find()` is a `&`static str`
24 let _
= "hello world".find("world").is_some();
25 let _
= "hello world".find(&s2
).is_some();
26 let _
= "hello world".find(&s2
[2..]).is_some();
27 // caller of `find()` is a `String`
28 let _
= s1
.find("world").is_some();
29 let _
= s1
.find(&s2
).is_some();
30 let _
= s1
.find(&s2
[2..]).is_some();
31 // caller of `find()` is slice of `String`
32 let _
= s1
[2..].find("world").is_some();
33 let _
= s1
[2..].find(&s2
).is_some();
34 let _
= s1
[2..].find(&s2
[2..]).is_some();
38 let v
= vec
![3, 2, 1, 0, -1, -2, -3];
41 // Check `find().is_none()`, single-line case.
42 let _
= v
.iter().find(|&x
| *x
< 0).is_none();
43 let _
= (0..1).find(|x
| **y
== *x
).is_none(); // one dereference less
44 let _
= (0..1).find(|x
| *x
== 0).is_none();
45 let _
= v
.iter().find(|x
| **x
== 0).is_none();
47 // Check `position().is_none()`, single-line case.
48 let _
= v
.iter().position(|&x
| x
< 0).is_none();
50 // Check `rposition().is_none()`, single-line case.
51 let _
= v
.iter().rposition(|&x
| x
< 0).is_none();
53 let s1
= String
::from("hello world");
54 let s2
= String
::from("world");
56 // caller of `find()` is a `&`static str`
57 let _
= "hello world".find("world").is_none();
58 let _
= "hello world".find(&s2
).is_none();
59 let _
= "hello world".find(&s2
[2..]).is_none();
60 // caller of `find()` is a `String`
61 let _
= s1
.find("world").is_none();
62 let _
= s1
.find(&s2
).is_none();
63 let _
= s1
.find(&s2
[2..]).is_none();
64 // caller of `find()` is slice of `String`
65 let _
= s1
[2..].find("world").is_none();
66 let _
= s1
[2..].find(&s2
).is_none();
67 let _
= s1
[2..].find(&s2
[2..]).is_none();