Some lint changes

Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>
This commit is contained in:
Hanif Bin Ariffin 2021-07-18 14:15:35 +08:00
parent 403910aed2
commit 6ff826b712

View file

@ -173,18 +173,14 @@ impl Sequence {
u32::from(a.chars().next().unwrap()), u32::from(a.chars().next().unwrap()),
u32::from(b.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( Sequence::CharRange(
(start..=end) (start..=end)
.map(|c| std::char::from_u32(c).unwrap()) .map(|c| std::char::from_u32(c).unwrap())
.collect(), .collect(),
) )
} else { } else {
Sequence::CharRange( Sequence::CharRange((start..=end).filter_map(std::char::from_u32).collect())
(start..=end)
.filter_map(|c| std::char::from_u32(c))
.collect(),
)
} }
}) })
}) })
@ -320,7 +316,7 @@ pub enum TranslateOperationNew {
impl TranslateOperationNew { impl TranslateOperationNew {
fn next_complement_char(mut iter: u32) -> (u32, char) { 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 = iter.saturating_add(1)
} }
(iter, char::from_u32(iter).unwrap()) (iter, char::from_u32(iter).unwrap())
@ -382,7 +378,7 @@ impl SymbolTranslatorNew for TranslateOperationNew {
if let Some(c) = set1.iter().find(|c| c.eq(&&current)) { if let Some(c) = set1.iter().find(|c| c.eq(&&current)) {
Some(*c) Some(*c)
} else { } else {
while let None = mapped_characters.get(&current) { while mapped_characters.get(&current).is_none() {
if let Some(p) = set2.pop() { if let Some(p) = set2.pop() {
let (next_index, next_value) = let (next_index, next_value) =
TranslateOperationNew::next_complement_char(*iter); TranslateOperationNew::next_complement_char(*iter);