1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
10 #[deny(clippy::naive_bytecount)]
12 let x = vec![0_u8; 16];
14 let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count
16 let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); // naive byte count
18 let _ = x.iter().filter(|a| **a > 0).count(); // not an equality count, OK.
20 let _ = x.iter().map(|a| a + 1).filter(|&a| a < 15).count(); // not a slice
24 let _ = x.iter().filter(|_| b > 0).count(); // woah there
26 let _ = x.iter().filter(|_a| b == b + 1).count(); // nothing to see here, move along
28 let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count
30 let y = vec![0_u16; 3];
32 let _ = y.iter().filter(|&&a| a == 0).count(); // naive count, but not bytes