]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | #![allow(dead_code, unused_variables)] |
2 | ||
3 | /// Utility macro to test linting behavior in `option_methods()` | |
4 | /// The lints included in `option_methods()` should not lint if the call to map is partially | |
5 | /// within a macro | |
6 | #[macro_export] | |
7 | macro_rules! opt_map { | |
8 | ($opt:expr, $map:expr) => { | |
9 | ($opt).map($map) | |
10 | }; | |
11 | } | |
12 | ||
13 | /// Struct to generate false positive for Iterator-based lints | |
14 | #[derive(Copy, Clone)] | |
15 | pub struct IteratorFalsePositives { | |
16 | pub foo: u32, | |
17 | } | |
18 | ||
19 | impl IteratorFalsePositives { | |
20 | pub fn filter(self) -> IteratorFalsePositives { | |
21 | self | |
22 | } | |
23 | ||
24 | pub fn next(self) -> IteratorFalsePositives { | |
25 | self | |
26 | } | |
27 | ||
28 | pub fn find(self) -> Option<u32> { | |
29 | Some(self.foo) | |
30 | } | |
31 | ||
32 | pub fn position(self) -> Option<u32> { | |
33 | Some(self.foo) | |
34 | } | |
35 | ||
36 | pub fn rposition(self) -> Option<u32> { | |
37 | Some(self.foo) | |
38 | } | |
39 | ||
40 | pub fn nth(self, n: usize) -> Option<u32> { | |
41 | Some(self.foo) | |
42 | } | |
43 | ||
44 | pub fn skip(self, _: usize) -> IteratorFalsePositives { | |
45 | self | |
46 | } | |
47 | ||
48 | pub fn skip_while(self) -> IteratorFalsePositives { | |
49 | self | |
50 | } | |
51 | ||
52 | pub fn count(self) -> usize { | |
53 | self.foo as usize | |
54 | } | |
55 | } |