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.
14 #[deny(clippy::naive_bytecount)]
16 let x = vec![0_u8; 16];
18 let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count
20 let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); // naive byte count
22 let _ = x.iter().filter(|a| **a > 0).count(); // not an equality count, OK.
24 let _ = x.iter().map(|a| a + 1).filter(|&a| a < 15).count(); // not a slice
28 let _ = x.iter().filter(|_| b > 0).count(); // woah there
30 let _ = x.iter().filter(|_a| b == b + 1).count(); // nothing to see here, move along
32 let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count
34 let y = vec![0_u16; 3];
36 let _ = y.iter().filter(|&&a| a == 0).count(); // naive count, but not bytes