We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 74caa63 commit 231c29bCopy full SHA for 231c29b
compiler/rustc_lexer/src/cursor.rs
@@ -164,16 +164,12 @@ impl<'a> Cursor<'a> {
164
/// Returns the found byte if any, or None if end of file was reached.
165
pub(crate) fn eat_past_either(&mut self, byte1: u8, byte2: u8) -> Option<u8> {
166
let bytes = self.as_str().as_bytes();
167
- match memchr::memchr2(byte1, byte2, bytes) {
168
- Some(index) => {
169
- let found = bytes[index];
170
- self.bump_bytes(index + 1);
171
- Some(found)
172
- }
173
- None => {
174
- self.chars = "".chars();
175
- None
176
+ if let Some(index) = memchr::memchr2(byte1, byte2, bytes) {
+ let found = Some(bytes[index]);
+ self.chars = self.as_str()[index + 1..].chars();
+ return found;
177
}
+ self.chars = "".chars();
+ None
178
179
0 commit comments