Skip to content

Commit 444b770

Browse files
committed
Make nextnextch() more closely resemble nextch().
1 parent 548067e commit 444b770

File tree

1 file changed

+7
-8
lines changed
  • src/libsyntax/parse/lexer

1 file changed

+7
-8
lines changed

src/libsyntax/parse/lexer/mod.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -477,15 +477,14 @@ impl<'a> StringReader<'a> {
477477

478478
pub fn nextnextch(&self) -> Option<char> {
479479
let next_src_index = self.src_index(self.next_pos);
480-
if next_src_index >= self.end_src_index {
481-
return None;
482-
}
483-
let next_next_src_index = next_src_index + char_at(&self.src, next_src_index).len_utf8();
484-
if next_next_src_index < self.end_src_index {
485-
Some(char_at(&self.src, next_next_src_index))
486-
} else {
487-
None
480+
if next_src_index < self.end_src_index {
481+
let next_next_src_index =
482+
next_src_index + char_at(&self.src, next_src_index).len_utf8();
483+
if next_next_src_index < self.end_src_index {
484+
return Some(char_at(&self.src, next_next_src_index));
485+
}
488486
}
487+
None
489488
}
490489

491490
pub fn nextnextch_is(&self, c: char) -> bool {

0 commit comments

Comments
 (0)