]>
Commit | Line | Data |
---|---|---|
1 | ||
2 | ||
3 | ||
4 | #[deny(naive_bytecount)] | |
5 | fn main() { | |
6 | let x = vec![0_u8; 16]; | |
7 | ||
8 | let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count | |
9 | ||
10 | let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); // naive byte count | |
11 | ||
12 | let _ = x.iter().filter(|a| **a > 0).count(); // not an equality count, OK. | |
13 | ||
14 | let _ = x.iter().map(|a| a + 1).filter(|&a| a < 15).count(); // not a slice | |
15 | ||
16 | let b = 0; | |
17 | ||
18 | let _ = x.iter().filter(|_| b > 0).count(); // woah there | |
19 | ||
20 | let _ = x.iter().filter(|_a| b == b + 1).count(); // nothing to see here, move along | |
21 | ||
22 | let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count | |
23 | ||
24 | let y = vec![0_u16; 3]; | |
25 | ||
26 | let _ = y.iter().filter(|&&a| a == 0).count(); // naive count, but not bytes | |
27 | } |