diff --git a/src/svg.rs b/src/svg.rs index 6e88674a..2e2a605d 100644 --- a/src/svg.rs +++ b/src/svg.rs @@ -280,9 +280,9 @@ impl<'a> SvgLexer<'a> { fn get_cmd(&mut self, last_cmd: u8) -> Option { self.skip_ws(); if let Some(c) = self.get_byte() { - if (b'a'..=b'z').contains(&c) || (b'A'..=b'Z').contains(&c) { + if c.is_ascii_lowercase() || c.is_ascii_uppercase() { return Some(c); - } else if last_cmd != 0 && (c == b'-' || c == b'.' || (b'0'..=b'9').contains(&c)) { + } else if last_cmd != 0 && (c == b'-' || c == b'.' || c.is_ascii_digit()) { // Plausible number start self.unget(); return Some(last_cmd); @@ -314,7 +314,7 @@ impl<'a> SvgLexer<'a> { let mut digit_count = 0; let mut seen_period = false; while let Some(c) = self.get_byte() { - if (b'0'..=b'9').contains(&c) { + if c.is_ascii_digit() { digit_count += 1; } else if c == b'.' && !seen_period { seen_period = true; @@ -329,11 +329,11 @@ impl<'a> SvgLexer<'a> { if c == b'-' || c == b'+' { c = self.get_byte().ok_or(SvgParseError::Wrong)? } - if !(b'0'..=b'9').contains(&c) { + if c.is_ascii_digit() { return Err(SvgParseError::Wrong); } while let Some(c) = self.get_byte() { - if !(b'0'..=b'9').contains(&c) { + if c.is_ascii_digit() { self.unget(); break; } @@ -370,7 +370,7 @@ impl<'a> SvgLexer<'a> { fn get_maybe_relative(&mut self, cmd: u8) -> Result { let pt = self.get_number_pair()?; - if (b'a'..=b'z').contains(&cmd) { + if cmd.is_ascii_lowercase() { Ok(self.last_pt + pt.to_vec2()) } else { Ok(pt)