Skip to content

Commit

Permalink
remove unecessary option
Browse files Browse the repository at this point in the history
  • Loading branch information
schneedotdev committed Mar 7, 2024
1 parent 50bc5fe commit 96a4b15
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl<'a> Lexer<'a> {
}
}

fn group_while<F>(&mut self, start: usize, c: char, condition: F) -> Option<&str>
fn group_while<F>(&mut self, start: usize, c: char, condition: F) -> &str
where
F: Fn(char) -> bool,
{
Expand All @@ -25,7 +25,7 @@ impl<'a> Lexer<'a> {
end = i + c.len_utf8();
}

Some(&self.input[start..end])
&self.input[start..end]
}
}

Expand All @@ -52,12 +52,12 @@ impl<'a> Iterator for Lexer<'a> {
'>' => Token::GreaterThan,
_ if c.is_alphabetic() => {
let value = self.group_while(i, c, char::is_alphabetic);
Token::Ident(value?.into())
Token::Ident(value.into())
}
_ if c.is_numeric() => {
let value = self.group_while(i, c, char::is_numeric);

match value?.parse() {
match value.parse() {
Ok(val) => Token::Int(val),
Err(_) => Token::Illegal,
}
Expand Down

0 comments on commit 96a4b15

Please sign in to comment.