Skip to content

Commit 07ffd04

Browse files
committed
Convert cooked_byte_string trailing backslash logic to bytes
1 parent 231e8c8 commit 07ffd04

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/parse.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -465,17 +465,17 @@ fn cooked_byte_string(mut input: Cursor) -> Result<Cursor, Reject> {
465465
Some((_, b'n')) | Some((_, b'r')) | Some((_, b't')) | Some((_, b'\\'))
466466
| Some((_, b'0')) | Some((_, b'\'')) | Some((_, b'"')) => {}
467467
Some((newline, b @ b'\n')) | Some((newline, b @ b'\r')) => {
468-
let mut last = b as char;
468+
let mut last = b;
469469
let rest = input.advance(newline + 1);
470-
let mut chars = rest.char_indices();
470+
let mut whitespace = rest.bytes().enumerate();
471471
loop {
472-
if last == '\r' && chars.next().map_or(true, |(_, ch)| ch != '\n') {
472+
if last == b'\r' && whitespace.next().map_or(true, |(_, b)| b != b'\n') {
473473
return Err(Reject);
474474
}
475-
match chars.next() {
476-
Some((_, ch @ ' ')) | Some((_, ch @ '\t')) | Some((_, ch @ '\n'))
477-
| Some((_, ch @ '\r')) => {
478-
last = ch;
475+
match whitespace.next() {
476+
Some((_, b @ b' ')) | Some((_, b @ b'\t')) | Some((_, b @ b'\n'))
477+
| Some((_, b @ b'\r')) => {
478+
last = b;
479479
}
480480
Some((offset, _)) => {
481481
input = rest.advance(offset);

0 commit comments

Comments
 (0)