|
97 | 97 | }
|
98 | 98 | Str | ByteStr => unescape_non_raw_common(src, mode, callback),
|
99 | 99 | RawStr | RawByteStr => check_raw_common(src, mode, callback),
|
100 |
| - CStr | RawCStr => unreachable!(), |
| 100 | + RawCStr => check_raw_common(src, mode, &mut |r, mut result| { |
| 101 | + if let Ok('\0') = result { |
| 102 | + result = Err(EscapeError::NulInCStr); |
| 103 | + } |
| 104 | + callback(r, result) |
| 105 | + }), |
| 106 | + CStr => unreachable!(), |
101 | 107 | }
|
102 | 108 | }
|
103 | 109 |
|
@@ -141,24 +147,13 @@ where
|
141 | 147 | F: FnMut(Range<usize>, Result<MixedUnit, EscapeError>),
|
142 | 148 | {
|
143 | 149 | match mode {
|
144 |
| - CStr => { |
145 |
| - unescape_non_raw_common(src, mode, &mut |r, mut result| { |
146 |
| - if let Ok(MixedUnit::Char('\0')) = result { |
147 |
| - result = Err(EscapeError::NulInCStr); |
148 |
| - } |
149 |
| - callback(r, result) |
150 |
| - }); |
151 |
| - } |
152 |
| - RawCStr => { |
153 |
| - check_raw_common(src, mode, &mut |r, mut result| { |
154 |
| - if let Ok('\0') = result { |
155 |
| - result = Err(EscapeError::NulInCStr); |
156 |
| - } |
157 |
| - // High bytes aren't possible in raw strings. |
158 |
| - callback(r, result.map(MixedUnit::Char)) |
159 |
| - }); |
160 |
| - } |
161 |
| - Char | Byte | Str | RawStr | ByteStr | RawByteStr => unreachable!(), |
| 150 | + CStr => unescape_non_raw_common(src, mode, &mut |r, mut result| { |
| 151 | + if let Ok(MixedUnit::Char('\0')) = result { |
| 152 | + result = Err(EscapeError::NulInCStr); |
| 153 | + } |
| 154 | + callback(r, result) |
| 155 | + }), |
| 156 | + Char | Byte | Str | RawStr | ByteStr | RawByteStr | RawCStr => unreachable!(), |
162 | 157 | }
|
163 | 158 | }
|
164 | 159 |
|
|
0 commit comments