diff options
| author | Nicholas Nethercote <nnethercote@mozilla.com> | 2018-05-09 13:20:55 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <nnethercote@mozilla.com> | 2018-05-14 10:00:39 +1000 |
| commit | 444b770f4cd8d817e7b7fec683ea301620034d13 (patch) | |
| tree | 32e62e8e73afccf0ce95700dfb6b9fbcf9221069 /src/libsyntax/parse | |
| parent | 548067e00f64861915d2374082adc7796c73ceb8 (diff) | |
| download | rust-444b770f4cd8d817e7b7fec683ea301620034d13.tar.gz rust-444b770f4cd8d817e7b7fec683ea301620034d13.zip | |
Make `nextnextch()` more closely resemble `nextch()`.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index f80eaf0a9b4..3968b7f113b 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -477,15 +477,14 @@ impl<'a> StringReader<'a> { pub fn nextnextch(&self) -> Option<char> { let next_src_index = self.src_index(self.next_pos); - if next_src_index >= self.end_src_index { - return None; - } - let next_next_src_index = next_src_index + char_at(&self.src, next_src_index).len_utf8(); - if next_next_src_index < self.end_src_index { - Some(char_at(&self.src, next_next_src_index)) - } else { - None + if next_src_index < self.end_src_index { + let next_next_src_index = + next_src_index + char_at(&self.src, next_src_index).len_utf8(); + if next_next_src_index < self.end_src_index { + return Some(char_at(&self.src, next_next_src_index)); + } } + None } pub fn nextnextch_is(&self, c: char) -> bool { |
