2021-12-17 12:40:22 +00:00
|
|
|
#![allow(dead_code, unused_variables, clippy::return_self_not_must_use)]
|
2019-01-02 21:48:44 +00:00
|
|
|
|
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
|
|
|
|
}
|
2020-01-20 01:54:54 +00:00
|
|
|
|
|
|
|
pub fn skip_while(self) -> IteratorFalsePositives {
|
|
|
|
self
|
|
|
|
}
|
2021-03-12 14:30:50 +00:00
|
|
|
|
|
|
|
pub fn count(self) -> usize {
|
|
|
|
self.foo as usize
|
|
|
|
}
|
2019-01-02 06:27:47 +00:00
|
|
|
}
|
2021-09-08 14:31:47 +00:00
|
|
|
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
pub struct IteratorMethodFalsePositives;
|
|
|
|
|
|
|
|
impl IteratorMethodFalsePositives {
|
|
|
|
pub fn filter(&self, _s: i32) -> std::vec::IntoIter<i32> {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
}
|