Skip to content

Commit

Permalink
replace type with type alias
Browse files Browse the repository at this point in the history
  • Loading branch information
danilopedraza committed Apr 18, 2024
1 parent ff0b53a commit 70965a9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ impl Iterator for Lexer<'_> {
}
}

type LexerResult = Result<Token, LexerError>;

impl Lexer<'_> {
fn next_char(&mut self) -> Option<char> {
match self.input.next() {
Expand All @@ -113,7 +115,7 @@ impl Lexer<'_> {
}
}

fn next_token(&mut self) -> Option<Result<Token, LexerError>> {
fn next_token(&mut self) -> Option<LexerResult> {
match self.next_char() {
None => None,
Some('\'') => self.char(),
Expand Down Expand Up @@ -154,7 +156,7 @@ impl Lexer<'_> {
})),
}
}
fn string_(&mut self) -> Result<Token, LexerError> {
fn string_(&mut self) -> LexerResult {
let mut str = String::new();

loop {
Expand All @@ -166,7 +168,7 @@ impl Lexer<'_> {
}
}

fn char(&mut self) -> Option<Result<Token, LexerError>> {
fn char(&mut self) -> Option<LexerResult> {
let chr = self.next_char();
if chr.is_none() {
return Some(Err(LexerError::UnexpectedEOF));
Expand Down

0 comments on commit 70965a9

Please sign in to comment.