From 07ffd046a7ad8043ed3ebec81560b2cc2ffcfce1 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 24 Jun 2023 15:56:50 -0700 Subject: [PATCH] Convert cooked_byte_string trailing backslash logic to bytes --- src/parse.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/parse.rs b/src/parse.rs index 0dac214..d48e974 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -465,17 +465,17 @@ fn cooked_byte_string(mut input: Cursor) -> Result { Some((_, b'n')) | Some((_, b'r')) | Some((_, b't')) | Some((_, b'\\')) | Some((_, b'0')) | Some((_, b'\'')) | Some((_, b'"')) => {} Some((newline, b @ b'\n')) | Some((newline, b @ b'\r')) => { - let mut last = b as char; + let mut last = b; let rest = input.advance(newline + 1); - let mut chars = rest.char_indices(); + let mut whitespace = rest.bytes().enumerate(); loop { - if last == '\r' && chars.next().map_or(true, |(_, ch)| ch != '\n') { + if last == b'\r' && whitespace.next().map_or(true, |(_, b)| b != b'\n') { return Err(Reject); } - match chars.next() { - Some((_, ch @ ' ')) | Some((_, ch @ '\t')) | Some((_, ch @ '\n')) - | Some((_, ch @ '\r')) => { - last = ch; + match whitespace.next() { + Some((_, b @ b' ')) | Some((_, b @ b'\t')) | Some((_, b @ b'\n')) + | Some((_, b @ b'\r')) => { + last = b; } Some((offset, _)) => { input = rest.advance(offset);