]> git.lizzy.rs Git - rust.git/blob - tests/ui/bytecount.rs
Merge commit '7ea7cd165ad6705603852771bf82cc2fd6560db5' into clippyup2
[rust.git] / tests / ui / bytecount.rs
1 #[deny(clippy::naive_bytecount)]
2 fn main() {
3     let x = vec![0_u8; 16];
4
5     let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count
6
7     let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); // naive byte count
8
9     let _ = x.iter().filter(|a| **a > 0).count(); // not an equality count, OK.
10
11     let _ = x.iter().map(|a| a + 1).filter(|&a| a < 15).count(); // not a slice
12
13     let b = 0;
14
15     let _ = x.iter().filter(|_| b > 0).count(); // woah there
16
17     let _ = x.iter().filter(|_a| b == b + 1).count(); // nothing to see here, move along
18
19     let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count
20
21     let y = vec![0_u16; 3];
22
23     let _ = y.iter().filter(|&&a| a == 0).count(); // naive count, but not bytes
24 }