]> git.lizzy.rs Git - rust.git/commitdiff
Make `nextnextch()` more closely resemble `nextch()`.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 9 May 2018 03:20:55 +0000 (13:20 +1000)
committerNicholas Nethercote <nnethercote@mozilla.com>
Mon, 14 May 2018 00:00:39 +0000 (10:00 +1000)
src/libsyntax/parse/lexer/mod.rs

index f80eaf0a9b446f7ec8b85ab8f8c7c604a38d41c0..3968b7f113b95378bc3e7e3fd6a0a45095a6952a 100644 (file)
@@ -477,15 +477,14 @@ pub fn nextch_is(&self, c: char) -> bool {
 
     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 {