From 6f272ef03167be086f0f62ddd397b038e8d1a2c0 Mon Sep 17 00:00:00 2001 From: Carlos Sousa Date: Wed, 2 Jul 2025 20:49:53 -0300 Subject: [PATCH 1/3] fix linting errors --- src/domain.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/domain.rs b/src/domain.rs index 5eaf88d..05f6bfe 100644 --- a/src/domain.rs +++ b/src/domain.rs @@ -18,7 +18,7 @@ pub fn to_ascii(domain: &str) -> Result, IdnaError> { // Fast path: check if the whole domain is valid ASCII and doesn't need transformation let mut label_start = 0; - let mut all_ascii = true; + let mut _all_ascii = true; let mut needs_alloc = false; let bytes = domain.as_bytes(); let mut i = 0; @@ -34,7 +34,7 @@ pub fn to_ascii(domain: &str) -> Result, IdnaError> { } label_start = i + 1; } else if bytes[i] >= 128 { - all_ascii = false; + _all_ascii = false; } i += 1; } @@ -102,7 +102,7 @@ fn process_label_to_ascii(label: &str) -> Result, IdnaError> { all_lower = false; break; } - if !(b'a'..=b'z').contains(&b) && !(b'0'..=b'9').contains(&b) && b != b'-' { + if !b.is_ascii_lowercase() && !b.is_ascii_digit() && b != b'-' { // Not lowercase ASCII, digit, or hyphen all_lower = false; break; From bd0f4fd691e200d3ed4354c1a7bd09ac7b765748 Mon Sep 17 00:00:00 2001 From: Carlos Sousa Date: Wed, 2 Jul 2025 20:52:51 -0300 Subject: [PATCH 2/3] format file --- src/domain.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/domain.rs b/src/domain.rs index 05f6bfe..53eda3f 100644 --- a/src/domain.rs +++ b/src/domain.rs @@ -29,7 +29,7 @@ pub fn to_ascii(domain: &str) -> Result, IdnaError> { return Err(IdnaError::EmptyLabel); } match process_label_to_ascii(label)? { - Cow::Borrowed(_) => {}, + Cow::Borrowed(_) => {} Cow::Owned(_) => needs_alloc = true, } label_start = i + 1; From 4ac14433139700e9ac017a8efececa17445e036a Mon Sep 17 00:00:00 2001 From: Carlos Sousa Date: Wed, 2 Jul 2025 21:51:41 -0300 Subject: [PATCH 3/3] remove _all_ascii variable --- src/domain.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/domain.rs b/src/domain.rs index 53eda3f..0a073a4 100644 --- a/src/domain.rs +++ b/src/domain.rs @@ -18,7 +18,6 @@ pub fn to_ascii(domain: &str) -> Result, IdnaError> { // Fast path: check if the whole domain is valid ASCII and doesn't need transformation let mut label_start = 0; - let mut _all_ascii = true; let mut needs_alloc = false; let bytes = domain.as_bytes(); let mut i = 0; @@ -33,8 +32,6 @@ pub fn to_ascii(domain: &str) -> Result, IdnaError> { Cow::Owned(_) => needs_alloc = true, } label_start = i + 1; - } else if bytes[i] >= 128 { - _all_ascii = false; } i += 1; }