2 #![warn(clippy::bytes_count_to_len)]
7 // should fix, because type is String
8 let _ = String::from("foo").bytes().count();
10 let s1 = String::from("foo");
11 let _ = s1.bytes().count();
13 // should fix, because type is &str
14 let _ = "foo".bytes().count();
17 let _ = s2.bytes().count();
19 // make sure using count() normally doesn't trigger warning
20 let vector = [0, 1, 2];
21 let _ = vector.iter().count();
23 // The type is slice, so should not fix
24 let _ = &[1, 2, 3].bytes().count();
26 let bytes: &[u8] = &[1, 2, 3];
27 bytes.bytes().count();
29 // The type is File, so should not fix
30 let _ = File::open("foobar").unwrap().bytes().count();
32 let f = File::open("foobar").unwrap();
33 let _ = f.bytes().count();