Implement clippy suggestions

This commit is contained in:
Henry Schimke
2023-01-04 14:48:16 -06:00
parent c65eadf102
commit 48287631dd
196 changed files with 2465 additions and 2574 deletions

View File

@@ -33,9 +33,10 @@ use crate::common::StringUtils;
fn test_random() {
let mut r = rand::thread_rng();
let mut bytes: Vec<u8> = vec![0; 1000];
for i in 0..bytes.len() {
bytes[i] = r.gen();
}
bytes.fill_with(|| r.gen());
// for byte in &mut bytes {
// *byte = r.gen();
// }
assert_eq!(
encoding::all::UTF_8.name(),
StringUtils::guessCharset(&bytes, &HashMap::new()).name()
@@ -102,7 +103,7 @@ fn test_utf16_le() {
);
}
fn do_test(bytes: &Vec<u8>, charset: EncodingRef, encoding: &str) {
fn do_test(bytes: &[u8], charset: EncodingRef, encoding: &str) {
let guessedCharset = StringUtils::guessCharset(bytes, &HashMap::new());
let guessedEncoding = StringUtils::guessEncoding(bytes, &HashMap::new());
assert_eq!(charset.name(), guessedCharset.name());