all: clippy

This commit is contained in:
Ryan Chandler 2022-07-16 20:42:45 +01:00
parent 4f5800df88
commit ce70d1f550
No known key found for this signature in database
GPG Key ID: F113BCADDB3B0CCA
2 changed files with 9 additions and 13 deletions

View File

@ -8,16 +8,13 @@ pub enum LexerState {
Scripting,
}
#[allow(dead_code)]
#[derive(Default)]
pub struct LexerConfig {
short_tags: bool,
}
impl Default for LexerConfig {
fn default() -> Self {
Self { short_tags: false }
}
}
#[allow(dead_code)]
pub struct Lexer {
config: LexerConfig,
state: LexerState,
@ -26,7 +23,7 @@ pub struct Lexer {
impl Lexer {
pub fn new(config: Option<LexerConfig>) -> Self {
Self {
config: config.unwrap_or(LexerConfig::default()),
config: config.unwrap_or_default(),
state: LexerState::Initial,
}
}
@ -35,7 +32,7 @@ impl Lexer {
let mut tokens = Vec::new();
let mut it = input.chars().peekable();
while let Some(_) = it.peek() {
while it.peek().is_some() {
match self.state {
// The "Initial" state is used to parse inline HTML. It is essentially a catch-all
// state that will build up a single token buffer until it encounters an open tag
@ -55,7 +52,7 @@ impl Lexer {
}
// If we have consumed whitespace and then reached the end of the file, we should break.
if let None = it.peek() {
if it.peek().is_none() {
break;
}
@ -131,7 +128,7 @@ impl Lexer {
fn scripting(&mut self, it: &mut Peekable<Chars>) -> Result<Token, LexerError> {
// We should never reach this point since we have the empty checks surrounding
// the call to this function, but it's better to be safe than sorry.
if let None = it.peek() {
if it.peek().is_none() {
return Err(LexerError::UnexpectedEndOfFile);
}

View File

@ -28,6 +28,7 @@ pub struct Parser {
}
#[allow(dead_code)]
impl Parser {
pub fn new() -> Self {
Self {}
@ -134,7 +135,7 @@ impl Parser {
}
fn expression(&self, tokens: &mut Peekable<IntoIter<Token>>, bp: u8) -> Result<Expression, ParseError> {
if let None = tokens.peek() {
if tokens.peek().is_none() {
return Err(ParseError::UnexpectedEndOfFile);
}
@ -148,8 +149,6 @@ impl Parser {
};
loop {
let t = tokens.peek();
let kind = match tokens.peek() {
Some(Token { kind: TokenKind::SemiColon, .. }) | None => break,
Some(Token { kind, .. }) => kind.clone(),