2019-01-02 15:48:44 -06:00
|
|
|
#![allow(dead_code, unused_variables)]
|
|
|
|
|
2019-01-02 00:23:00 -06: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 15:48:44 -06:00
|
|
|
#[macro_export]
|
2019-01-02 00:23:00 -06:00
|
|
|
macro_rules! opt_map {
|
2019-01-02 01:15:32 -06:00
|
|
|
($opt:expr, $map:expr) => {
|
|
|
|
($opt).map($map)
|
|
|
|
};
|
2019-01-02 00:23:00 -06:00
|
|
|
}
|
2019-01-02 00:27:47 -06:00
|
|
|
|
|
|
|
/// Struct to generate false positive for Iterator-based lints
|
|
|
|
#[derive(Copy, Clone)]
|
2019-01-02 15:48:44 -06:00
|
|
|
pub struct IteratorFalsePositives {
|
|
|
|
pub foo: u32,
|
2019-01-02 00:27:47 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
impl IteratorFalsePositives {
|
2019-01-02 15:48:44 -06:00
|
|
|
pub fn filter(self) -> IteratorFalsePositives {
|
2019-01-02 00:27:47 -06:00
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2019-01-02 15:48:44 -06:00
|
|
|
pub fn next(self) -> IteratorFalsePositives {
|
2019-01-02 00:27:47 -06:00
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2019-01-02 15:48:44 -06:00
|
|
|
pub fn find(self) -> Option<u32> {
|
2019-01-02 00:27:47 -06:00
|
|
|
Some(self.foo)
|
|
|
|
}
|
|
|
|
|
2019-01-02 15:48:44 -06:00
|
|
|
pub fn position(self) -> Option<u32> {
|
2019-01-02 00:27:47 -06:00
|
|
|
Some(self.foo)
|
|
|
|
}
|
|
|
|
|
2019-01-02 15:48:44 -06:00
|
|
|
pub fn rposition(self) -> Option<u32> {
|
2019-01-02 00:27:47 -06:00
|
|
|
Some(self.foo)
|
|
|
|
}
|
|
|
|
|
2019-01-02 15:48:44 -06:00
|
|
|
pub fn nth(self, n: usize) -> Option<u32> {
|
2019-01-02 00:27:47 -06:00
|
|
|
Some(self.foo)
|
|
|
|
}
|
|
|
|
|
2019-01-02 15:48:44 -06:00
|
|
|
pub fn skip(self, _: usize) -> IteratorFalsePositives {
|
2019-01-02 00:27:47 -06:00
|
|
|
self
|
|
|
|
}
|
2020-01-19 19:54:54 -06:00
|
|
|
|
|
|
|
pub fn skip_while(self) -> IteratorFalsePositives {
|
|
|
|
self
|
|
|
|
}
|
2021-02-25 08:06:50 -06:00
|
|
|
|
|
|
|
pub fn count(self) -> usize {
|
|
|
|
self.foo as usize
|
|
|
|
}
|
2019-01-02 00:27:47 -06:00
|
|
|
}
|
2021-08-13 01:34:33 -05:00
|
|
|
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
pub struct IteratorMethodFalsePositives;
|
|
|
|
|
|
|
|
impl IteratorMethodFalsePositives {
|
|
|
|
pub fn filter(&self, _s: i32) -> std::vec::IntoIter<i32> {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
}
|