Make Clippy happy with is_ascii_*
methods (#1159)
This commit is contained in:
parent
91064e9554
commit
42ad693fcb
2 changed files with 4 additions and 15 deletions
|
@ -515,15 +515,15 @@ fn is_source_char(c: char) -> bool {
|
|||
}
|
||||
|
||||
fn is_name_start(c: char) -> bool {
|
||||
c == '_' || ('A'..='Z').contains(&c) || ('a'..='z').contains(&c)
|
||||
c == '_' || c.is_ascii_alphabetic()
|
||||
}
|
||||
|
||||
fn is_name_cont(c: char) -> bool {
|
||||
is_name_start(c) || ('0'..='9').contains(&c)
|
||||
is_name_start(c) || c.is_ascii_digit()
|
||||
}
|
||||
|
||||
fn is_number_start(c: char) -> bool {
|
||||
c == '-' || ('0'..='9').contains(&c)
|
||||
c == '-' || c.is_ascii_digit()
|
||||
}
|
||||
|
||||
impl fmt::Display for LexerError {
|
||||
|
|
|
@ -5,24 +5,13 @@ use std::{
|
|||
str::FromStr,
|
||||
};
|
||||
|
||||
// Helper functions until the corresponding AsciiExt methods
|
||||
// stabilise (https://github.com/rust-lang/rust/issues/39658).
|
||||
|
||||
fn is_ascii_alphabetic(c: char) -> bool {
|
||||
('a'..='z').contains(&c) || ('A'..='Z').contains(&c)
|
||||
}
|
||||
|
||||
fn is_ascii_digit(c: char) -> bool {
|
||||
('0'..='9').contains(&c)
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct Name(String);
|
||||
|
||||
impl Name {
|
||||
pub fn is_valid(input: &str) -> bool {
|
||||
for (i, c) in input.chars().enumerate() {
|
||||
let is_valid = is_ascii_alphabetic(c) || c == '_' || (i > 0 && is_ascii_digit(c));
|
||||
let is_valid = c.is_ascii_alphabetic() || c == '_' || (i > 0 && c.is_ascii_digit());
|
||||
if !is_valid {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue