Skip to content

Commit

Permalink
Use while-match construct instead of loop in skip_whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
phrohdoh committed Dec 12, 2016
1 parent 3f6afc2 commit d3f3b5d
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/lexer.rs
Expand Up @@ -93,15 +93,11 @@ impl<'a> Lexer<'a> {


fn skip_whitespace(&mut self) { fn skip_whitespace(&mut self) {
// Loop read_char() until non-whitespace is found // Loop read_char() until non-whitespace is found
loop { while match self.ch {
match self.ch { Some(ch) => ch.is_whitespace(),
Some(' ') => self.read_char(), _ => false,
Some('\t') => self.read_char(), } {
Some('\n') => self.read_char(), self.read_char();
Some('\r') => self.read_char(),
Some(_) => return,
None => return, // EOF is handled by caller
}
} }
} }


Expand Down

0 comments on commit d3f3b5d

Please sign in to comment.