@@ -163,7 +163,7 @@ pub(super) fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> {
163
163
// %xF4 %x80-8F 2( UTF8-tail )
164
164
match w {
165
165
2 => {
166
- if next ! ( ) & ! CONT_MASK != TAG_CONT_U8 {
166
+ if ! utf8_is_cont_byte ( next ! ( ) ) {
167
167
err ! ( Some ( 1 ) )
168
168
}
169
169
}
@@ -175,7 +175,7 @@ pub(super) fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> {
175
175
| ( 0xEE ..=0xEF , 0x80 ..=0xBF ) => { }
176
176
_ => err ! ( Some ( 1 ) ) ,
177
177
}
178
- if next ! ( ) & ! CONT_MASK != TAG_CONT_U8 {
178
+ if ! utf8_is_cont_byte ( next ! ( ) ) {
179
179
err ! ( Some ( 2 ) )
180
180
}
181
181
}
@@ -184,10 +184,10 @@ pub(super) fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> {
184
184
( 0xF0 , 0x90 ..=0xBF ) | ( 0xF1 ..=0xF3 , 0x80 ..=0xBF ) | ( 0xF4 , 0x80 ..=0x8F ) => { }
185
185
_ => err ! ( Some ( 1 ) ) ,
186
186
}
187
- if next ! ( ) & ! CONT_MASK != TAG_CONT_U8 {
187
+ if ! utf8_is_cont_byte ( next ! ( ) ) {
188
188
err ! ( Some ( 2 ) )
189
189
}
190
- if next ! ( ) & ! CONT_MASK != TAG_CONT_U8 {
190
+ if ! utf8_is_cont_byte ( next ! ( ) ) {
191
191
err ! ( Some ( 3 ) )
192
192
}
193
193
}
@@ -258,8 +258,6 @@ pub fn utf8_char_width(b: u8) -> usize {
258
258
259
259
/// Mask of the value bits of a continuation byte.
260
260
const CONT_MASK : u8 = 0b0011_1111 ;
261
- /// Value of the tag bits (tag mask is !CONT_MASK) of a continuation byte.
262
- const TAG_CONT_U8 : u8 = 0b1000_0000 ;
263
261
264
262
// truncate `&str` to length at most equal to `max`
265
263
// return `true` if it were truncated, and the new str.
0 commit comments