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