1 // aux-build:option_helpers.rs
2 #![warn(clippy::search_is_some)]
4 extern crate option_helpers;
5 use option_helpers::IteratorFalsePositives;
9 let v = vec![3, 2, 1, 0, -1, -2, -3];
13 // Check `find().is_some()`, multi-line case.
14 let _ = v.iter().find(|&x| {
19 // Check `position().is_some()`, multi-line case.
20 let _ = v.iter().position(|&x| {
25 // Check `rposition().is_some()`, multi-line case.
26 let _ = v.iter().rposition(|&x| {
31 // Check that we don't lint if the caller is not an `Iterator` or string
32 let falsepos = IteratorFalsePositives { foo: 0 };
33 let _ = falsepos.find().is_some();
34 let _ = falsepos.position().is_some();
35 let _ = falsepos.rposition().is_some();
36 // check that we don't lint if `find()` is called with
37 // `Pattern` that is not a string
38 let _ = "hello world".find(|c: char| c == 'o' || c == 'l').is_some();
40 let some_closure = |x: &u32| *x == 0;
41 let _ = (0..1).find(some_closure).is_some();
46 let v = vec![3, 2, 1, 0, -1, -2, -3];
50 // Check `find().is_none()`, multi-line case.
51 let _ = v.iter().find(|&x| {
56 // Check `position().is_none()`, multi-line case.
57 let _ = v.iter().position(|&x| {
62 // Check `rposition().is_none()`, multi-line case.
63 let _ = v.iter().rposition(|&x| {
68 // Check that we don't lint if the caller is not an `Iterator` or string
69 let falsepos = IteratorFalsePositives { foo: 0 };
70 let _ = falsepos.find().is_none();
71 let _ = falsepos.position().is_none();
72 let _ = falsepos.rposition().is_none();
73 // check that we don't lint if `find()` is called with
74 // `Pattern` that is not a string
75 let _ = "hello world".find(|c: char| c == 'o' || c == 'l').is_none();
77 let some_closure = |x: &u32| *x == 0;
78 let _ = (0..1).find(some_closure).is_none();