|
92 | 92 | let res = unescape_char_or_byte(&mut chars, mode);
|
93 | 93 | callback(0..(src.len() - chars.as_str().len()), res);
|
94 | 94 | }
|
95 |
| - Str | ByteStr => unescape_str_common(src, mode, callback), |
96 |
| - RawStr | RawByteStr => unescape_raw_str_or_raw_byte_str(src, mode, callback), |
| 95 | + Str | ByteStr => unescape_non_raw_common(src, mode, callback), |
| 96 | + RawStr | RawByteStr => check_raw_common(src, mode, callback), |
97 | 97 | CStr | RawCStr => unreachable!(),
|
98 | 98 | }
|
99 | 99 | }
|
@@ -122,12 +122,10 @@ where
|
122 | 122 | {
|
123 | 123 | match mode {
|
124 | 124 | CStr => {
|
125 |
| - unescape_str_common(src, mode, callback); |
| 125 | + unescape_non_raw_common(src, mode, callback); |
126 | 126 | }
|
127 | 127 | RawCStr => {
|
128 |
| - unescape_raw_str_or_raw_byte_str(src, mode, &mut |r, result| { |
129 |
| - callback(r, result.map(CStrUnit::Char)) |
130 |
| - }); |
| 128 | + check_raw_common(src, mode, &mut |r, result| callback(r, result.map(CStrUnit::Char))); |
131 | 129 | }
|
132 | 130 | Char | Byte | Str | RawStr | ByteStr | RawByteStr => unreachable!(),
|
133 | 131 | }
|
@@ -325,7 +323,7 @@ fn unescape_char_or_byte(chars: &mut Chars<'_>, mode: Mode) -> Result<char, Esca
|
325 | 323 |
|
326 | 324 | /// Takes a contents of a string literal (without quotes) and produces a
|
327 | 325 | /// sequence of escaped characters or errors.
|
328 |
| -fn unescape_str_common<F, T: From<u8> + From<char>>(src: &str, mode: Mode, callback: &mut F) |
| 326 | +fn unescape_non_raw_common<F, T: From<u8> + From<char>>(src: &str, mode: Mode, callback: &mut F) |
329 | 327 | where
|
330 | 328 | F: FnMut(Range<usize>, Result<T, EscapeError>),
|
331 | 329 | {
|
@@ -392,15 +390,15 @@ where
|
392 | 390 | /// sequence of characters or errors.
|
393 | 391 | /// NOTE: Raw strings do not perform any explicit character escaping, here we
|
394 | 392 | /// only produce errors on bare CR.
|
395 |
| -fn unescape_raw_str_or_raw_byte_str<F>(src: &str, mode: Mode, callback: &mut F) |
| 393 | +fn check_raw_common<F>(src: &str, mode: Mode, callback: &mut F) |
396 | 394 | where
|
397 | 395 | F: FnMut(Range<usize>, Result<char, EscapeError>),
|
398 | 396 | {
|
399 | 397 | let mut chars = src.chars();
|
400 | 398 | let chars_should_be_ascii = mode.chars_should_be_ascii(); // get this outside the loop
|
401 | 399 |
|
402 | 400 | // The `start` and `end` computation here matches the one in
|
403 |
| - // `unescape_str_common` for consistency, even though this function |
| 401 | + // `unescape_non_raw_common` for consistency, even though this function |
404 | 402 | // doesn't have to worry about skipping any chars.
|
405 | 403 | while let Some(c) = chars.next() {
|
406 | 404 | let start = src.len() - chars.as_str().len() - c.len_utf8();
|
|
0 commit comments