Skip to content

Commit

Permalink
fix: follow clippy checks
Browse files Browse the repository at this point in the history
Signed-off-by: fan <yfan3763@gmail.com>
  • Loading branch information
fansehep committed Oct 29, 2023
1 parent 3704dab commit aef8f7d
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 171 deletions.
20 changes: 10 additions & 10 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ pub type Result<T> = core::result::Result<T, Error>;

#[derive(Clone, Debug, PartialEq)]
pub enum Error {
ParseErr(String),
StorageErr(String),
InternalErr(String),
ConfErr(String),
OtherErr(String),
Parse(String),
Storage(String),
Internal(String),
Conf(String),
Other(String),
}

impl Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::ParseErr(err)
| Self::StorageErr(err)
| Self::InternalErr(err)
| Self::ConfErr(err)
| Self::OtherErr(err) => {
Self::Parse(err)
| Self::Storage(err)
| Self::Internal(err)
| Self::Conf(err)
| Self::Other(err) => {
write!(f, "{}", err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/parser/keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl fmt::Display for Keyword {
}
}

pub fn find_keyword(keyword_str: &String) -> Keyword {
pub fn find_keyword(keyword_str: &str) -> Keyword {
// 转化为大写
let upper_keyword_str = keyword_str.to_uppercase();

Expand Down
4 changes: 2 additions & 2 deletions src/parser/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,12 @@ impl Lexer {

// 是否是 字母开头
fn is_letter(ch: char) -> bool {
(ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch == '_'
ch.is_ascii_alphabetic() || ch == '_'
}

// 是否是 数字
fn is_digit(ch: char) -> bool {
ch >= '0' && ch <= '9'
ch.is_numeric()
}

#[cfg(test)]
Expand Down
Loading

0 comments on commit aef8f7d

Please sign in to comment.