Permalink
Browse files

Use while-match construct instead of loop in skip_whitespace

  • Loading branch information...
Phrohdoh committed Dec 12, 2016
1 parent 3f6afc2 commit d3f3b5d6e211a323d49f86e7039ea14857365513
Showing with 5 additions and 9 deletions.
  1. +5 −9 src/lexer.rs
@@ -93,15 +93,11 @@ impl<'a> Lexer<'a> {
fn skip_whitespace(&mut self) {
// Loop read_char() until non-whitespace is found
loop {
match self.ch {
Some(' ') => self.read_char(),
Some('\t') => self.read_char(),
Some('\n') => self.read_char(),
Some('\r') => self.read_char(),
Some(_) => return,
None => return, // EOF is handled by caller
}
while match self.ch {
Some(ch) => ch.is_whitespace(),
_ => false,
} {
self.read_char();
}
}

0 comments on commit d3f3b5d

Please sign in to comment.