diff --git a/i18n/iconv.rs b/i18n/iconv.rs index 4ddae8d8..6cab1b23 100644 --- a/i18n/iconv.rs +++ b/i18n/iconv.rs @@ -147,9 +147,9 @@ impl IntoIterator for CircularBuffer { } } +#[allow(non_camel_case_types, clippy::upper_case_acronyms)] #[derive(EnumString, EnumIter, Debug, PartialEq, Display)] #[strum(serialize_all = "SCREAMING-KEBAB-CASE")] -#[allow(non_camel_case_types)] enum Encodings { ASCII, UTF_8, @@ -427,7 +427,7 @@ fn charmap_conversion( for byte in input { buffer.push(byte); let mut found = false; - for (_, entry) in &from.entries { + for entry in from.entries.values() { if buffer.starts_with(&entry.encoding) { if let Some(to_entry) = to .entries diff --git a/i18n/iconv_lib/ascii.rs b/i18n/iconv_lib/ascii.rs index 12270308..675cf538 100644 --- a/i18n/iconv_lib/ascii.rs +++ b/i18n/iconv_lib/ascii.rs @@ -17,8 +17,8 @@ pub fn to_ucs4 + 'static>( ) -> Box> { let mut position = 0; - let iter = std::iter::from_fn(move || { - while let Some(code_point) = input.next() { + let iter = iter::from_fn(move || { + for code_point in input.by_ref() { position += 1; if code_point <= 127 { return Some(code_point as u32); @@ -43,8 +43,9 @@ pub fn from_ucs4 + 'static>( suppress_error: bool, ) -> Box> { let mut position = 0; + let iter = iter::from_fn(move || { - while let Some(code_point) = input.next() { + for code_point in input.by_ref() { position += 1; if code_point <= 127 { return Some(code_point as u8); diff --git a/i18n/iconv_lib/utf_8.rs b/i18n/iconv_lib/utf_8.rs index a65ee364..17e1543e 100644 --- a/i18n/iconv_lib/utf_8.rs +++ b/i18n/iconv_lib/utf_8.rs @@ -33,7 +33,7 @@ pub fn to_ucs4 + 'static>( return Some(code_point); // 2 bytes - } else if byte >= 0xC0 && byte <= 0xDF { + } else if (0xC0..=0xDF).contains(&byte) { if buffer.len() < 2 { let add_bytes = input.by_ref().take(2 - buffer.len()).collect::>(); buffer.extend(add_bytes); @@ -76,7 +76,7 @@ pub fn to_ucs4 + 'static>( return Some(code_point); // 3 bytes - } else if byte >= 0xE0 && byte <= 0xEF { + } else if (0xE0..=0xEF).contains(&byte) { if buffer.len() < 3 { let add_bytes = input.by_ref().take(3 - buffer.len()).collect::>(); buffer.extend(add_bytes); @@ -121,7 +121,7 @@ pub fn to_ucs4 + 'static>( return Some(code_point); // 4 bytes - } else if byte >= 0xF0 && byte <= 0xF4 { + } else if (0xF0..=0xF4).contains(&byte) { if buffer.len() < 4 { let add_bytes = input.by_ref().take(4 - buffer.len()).collect::>(); buffer.extend(add_bytes); @@ -155,7 +155,7 @@ pub fn to_ucs4 + 'static>( | ((buffer[1] as u32 & 0x3F) << 12) | ((buffer[2] as u32 & 0x3F) << 6) | (buffer[3] as u32 & 0x3F); - if code_point > 0x10FFFF || code_point < 0x10000 { + if !(0x10000..=0x10FFFF).contains(&code_point) { if omit_invalid { buffer.drain(0..4); continue;