2019-01-02 21:48:44 +00:00
|
|
|
#![allow(dead_code, unused_variables)]
|
|
|
|
|
2019-01-02 06:23:00 +00:00
|
|
|
/// Utility macro to test linting behavior in `option_methods()`
|
|
|
|
/// The lints included in `option_methods()` should not lint if the call to map is partially
|
|
|
|
/// within a macro
|
2019-01-02 21:48:44 +00:00
|
|
|
#[macro_export]
|
2019-01-02 06:23:00 +00:00
|
|
|
macro_rules! opt_map {
|
2019-01-02 07:15:32 +00:00
|
|
|
($opt:expr, $map:expr) => {
|
|
|
|
($opt).map($map)
|
|
|
|
};
|
2019-01-02 06:23:00 +00:00
|
|
|
}
|
2019-01-02 06:27:47 +00:00
|
|
|
|
|
|
|
/// Struct to generate false positive for Iterator-based lints
|
|
|
|
#[derive(Copy, Clone)]
|
2019-01-02 21:48:44 +00:00
|
|
|
pub struct IteratorFalsePositives {
|
|
|
|
pub foo: u32,
|
2019-01-02 06:27:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl IteratorFalsePositives {
|
2019-01-02 21:48:44 +00:00
|
|
|
pub fn filter(self) -> IteratorFalsePositives {
|
2019-01-02 06:27:47 +00:00
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2019-01-02 21:48:44 +00:00
|
|
|
pub fn next(self) -> IteratorFalsePositives {
|
2019-01-02 06:27:47 +00:00
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2019-01-02 21:48:44 +00:00
|
|
|
pub fn find(self) -> Option<u32> {
|
2019-01-02 06:27:47 +00:00
|
|
|
Some(self.foo)
|
|
|
|
}
|
|
|
|
|
2019-01-02 21:48:44 +00:00
|
|
|
pub fn position(self) -> Option<u32> {
|
2019-01-02 06:27:47 +00:00
|
|
|
Some(self.foo)
|
|
|
|
}
|
|
|
|
|
2019-01-02 21:48:44 +00:00
|
|
|
pub fn rposition(self) -> Option<u32> {
|
2019-01-02 06:27:47 +00:00
|
|
|
Some(self.foo)
|
|
|
|
}
|
|
|
|
|
2019-01-02 21:48:44 +00:00
|
|
|
pub fn nth(self, n: usize) -> Option<u32> {
|
2019-01-02 06:27:47 +00:00
|
|
|
Some(self.foo)
|
|
|
|
}
|
|
|
|
|
2019-01-02 21:48:44 +00:00
|
|
|
pub fn skip(self, _: usize) -> IteratorFalsePositives {
|
2019-01-02 06:27:47 +00:00
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|