2019-01-02 22:48:44 +01:00
|
|
|
#![allow(dead_code, unused_variables)]
|
|
|
|
|
2019-01-02 07:23:00 +01: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 22:48:44 +01:00
|
|
|
#[macro_export]
|
2019-01-02 07:23:00 +01:00
|
|
|
macro_rules! opt_map {
|
2019-01-02 08:15:32 +01:00
|
|
|
($opt:expr, $map:expr) => {
|
|
|
|
($opt).map($map)
|
|
|
|
};
|
2019-01-02 07:23:00 +01:00
|
|
|
}
|
2019-01-02 07:27:47 +01:00
|
|
|
|
|
|
|
/// Struct to generate false positive for Iterator-based lints
|
|
|
|
#[derive(Copy, Clone)]
|
2019-01-02 22:48:44 +01:00
|
|
|
pub struct IteratorFalsePositives {
|
|
|
|
pub foo: u32,
|
2019-01-02 07:27:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
impl IteratorFalsePositives {
|
2019-01-02 22:48:44 +01:00
|
|
|
pub fn filter(self) -> IteratorFalsePositives {
|
2019-01-02 07:27:47 +01:00
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2019-01-02 22:48:44 +01:00
|
|
|
pub fn next(self) -> IteratorFalsePositives {
|
2019-01-02 07:27:47 +01:00
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2019-01-02 22:48:44 +01:00
|
|
|
pub fn find(self) -> Option<u32> {
|
2019-01-02 07:27:47 +01:00
|
|
|
Some(self.foo)
|
|
|
|
}
|
|
|
|
|
2019-01-02 22:48:44 +01:00
|
|
|
pub fn position(self) -> Option<u32> {
|
2019-01-02 07:27:47 +01:00
|
|
|
Some(self.foo)
|
|
|
|
}
|
|
|
|
|
2019-01-02 22:48:44 +01:00
|
|
|
pub fn rposition(self) -> Option<u32> {
|
2019-01-02 07:27:47 +01:00
|
|
|
Some(self.foo)
|
|
|
|
}
|
|
|
|
|
2019-01-02 22:48:44 +01:00
|
|
|
pub fn nth(self, n: usize) -> Option<u32> {
|
2019-01-02 07:27:47 +01:00
|
|
|
Some(self.foo)
|
|
|
|
}
|
|
|
|
|
2019-01-02 22:48:44 +01:00
|
|
|
pub fn skip(self, _: usize) -> IteratorFalsePositives {
|
2019-01-02 07:27:47 +01:00
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|