From 6ff826b712e67062a7035d104912bb46727fc682 Mon Sep 17 00:00:00 2001 From: Hanif Bin Ariffin Date: Sun, 18 Jul 2021 14:15:35 +0800 Subject: [PATCH] Some lint changes Signed-off-by: Hanif Bin Ariffin --- src/uu/tr/src/operation.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/uu/tr/src/operation.rs b/src/uu/tr/src/operation.rs index dd3e722ca..30e7b6af5 100644 --- a/src/uu/tr/src/operation.rs +++ b/src/uu/tr/src/operation.rs @@ -173,18 +173,14 @@ impl Sequence { u32::from(a.chars().next().unwrap()), u32::from(b.chars().next().unwrap()), ); - if start >= 48 && start <= 90 && end >= 48 && end <= 90 && end > start { + if (48..=90).contains(&start) && (48..=90).contains(&end) && end > start { Sequence::CharRange( (start..=end) .map(|c| std::char::from_u32(c).unwrap()) .collect(), ) } else { - Sequence::CharRange( - (start..=end) - .filter_map(|c| std::char::from_u32(c)) - .collect(), - ) + Sequence::CharRange((start..=end).filter_map(std::char::from_u32).collect()) } }) }) @@ -320,7 +316,7 @@ pub enum TranslateOperationNew { impl TranslateOperationNew { fn next_complement_char(mut iter: u32) -> (u32, char) { - while let None = char::from_u32(iter) { + while char::from_u32(iter).is_none() { iter = iter.saturating_add(1) } (iter, char::from_u32(iter).unwrap()) @@ -382,7 +378,7 @@ impl SymbolTranslatorNew for TranslateOperationNew { if let Some(c) = set1.iter().find(|c| c.eq(&¤t)) { Some(*c) } else { - while let None = mapped_characters.get(¤t) { + while mapped_characters.get(¤t).is_none() { if let Some(p) = set2.pop() { let (next_index, next_value) = TranslateOperationNew::next_complement_char(*iter);