Skip to content

Commit 05d848d

Browse files
authored
Merge pull request #345 from fox0/iconv
iconv: Fix clippy
2 parents 83f986d + f4d9ca9 commit 05d848d

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

i18n/iconv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ impl<R: Read> IntoIterator for CircularBuffer<R> {
147147
}
148148
}
149149

150+
#[allow(non_camel_case_types, clippy::upper_case_acronyms)]
150151
#[derive(EnumString, EnumIter, Debug, PartialEq, Display)]
151152
#[strum(serialize_all = "SCREAMING-KEBAB-CASE")]
152-
#[allow(non_camel_case_types)]
153153
enum Encodings {
154154
ASCII,
155155
UTF_8,
@@ -427,7 +427,7 @@ fn charmap_conversion(
427427
for byte in input {
428428
buffer.push(byte);
429429
let mut found = false;
430-
for (_, entry) in &from.entries {
430+
for entry in from.entries.values() {
431431
if buffer.starts_with(&entry.encoding) {
432432
if let Some(to_entry) = to
433433
.entries

i18n/iconv_lib/ascii.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ pub fn to_ucs4<I: Iterator<Item = u8> + 'static>(
1717
) -> Box<dyn Iterator<Item = u32>> {
1818
let mut position = 0;
1919

20-
let iter = std::iter::from_fn(move || {
21-
while let Some(code_point) = input.next() {
20+
let iter = iter::from_fn(move || {
21+
for code_point in input.by_ref() {
2222
position += 1;
2323
if code_point <= 127 {
2424
return Some(code_point as u32);
@@ -43,8 +43,9 @@ pub fn from_ucs4<I: Iterator<Item = u32> + 'static>(
4343
suppress_error: bool,
4444
) -> Box<dyn Iterator<Item = u8>> {
4545
let mut position = 0;
46+
4647
let iter = iter::from_fn(move || {
47-
while let Some(code_point) = input.next() {
48+
for code_point in input.by_ref() {
4849
position += 1;
4950
if code_point <= 127 {
5051
return Some(code_point as u8);

i18n/iconv_lib/utf_8.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub fn to_ucs4<I: Iterator<Item = u8> + 'static>(
3333
return Some(code_point);
3434

3535
// 2 bytes
36-
} else if byte >= 0xC0 && byte <= 0xDF {
36+
} else if (0xC0..=0xDF).contains(&byte) {
3737
if buffer.len() < 2 {
3838
let add_bytes = input.by_ref().take(2 - buffer.len()).collect::<Vec<_>>();
3939
buffer.extend(add_bytes);
@@ -76,7 +76,7 @@ pub fn to_ucs4<I: Iterator<Item = u8> + 'static>(
7676
return Some(code_point);
7777

7878
// 3 bytes
79-
} else if byte >= 0xE0 && byte <= 0xEF {
79+
} else if (0xE0..=0xEF).contains(&byte) {
8080
if buffer.len() < 3 {
8181
let add_bytes = input.by_ref().take(3 - buffer.len()).collect::<Vec<_>>();
8282
buffer.extend(add_bytes);
@@ -121,7 +121,7 @@ pub fn to_ucs4<I: Iterator<Item = u8> + 'static>(
121121
return Some(code_point);
122122

123123
// 4 bytes
124-
} else if byte >= 0xF0 && byte <= 0xF4 {
124+
} else if (0xF0..=0xF4).contains(&byte) {
125125
if buffer.len() < 4 {
126126
let add_bytes = input.by_ref().take(4 - buffer.len()).collect::<Vec<_>>();
127127
buffer.extend(add_bytes);
@@ -155,7 +155,7 @@ pub fn to_ucs4<I: Iterator<Item = u8> + 'static>(
155155
| ((buffer[1] as u32 & 0x3F) << 12)
156156
| ((buffer[2] as u32 & 0x3F) << 6)
157157
| (buffer[3] as u32 & 0x3F);
158-
if code_point > 0x10FFFF || code_point < 0x10000 {
158+
if !(0x10000..=0x10FFFF).contains(&code_point) {
159159
if omit_invalid {
160160
buffer.drain(0..4);
161161
continue;

0 commit comments

Comments
 (0)