(ptr: &mut *const u8)
| 272 | /// `bytes` must produce a valid UTF-8-like (UTF-8 or WTF-8) string |
| 273 | #[inline] |
| 274 | const unsafe fn next_code_point_reverse(ptr: &mut *const u8) -> u32 { |
| 275 | // Decode UTF-8 |
| 276 | *ptr = unsafe { ptr.offset(-1) }; |
| 277 | let w = match unsafe { **ptr } { |
| 278 | next_byte if next_byte < 128 => return next_byte as u32, |
| 279 | back_byte => back_byte, |
| 280 | }; |
| 281 | |
| 282 | // Multibyte case follows |
| 283 | // Decode from a byte combination out of: [x [y [z w]]] |
| 284 | let mut ch; |
| 285 | // SAFETY: `bytes` produces an UTF-8-like string, |
| 286 | // so the iterator must produce a value here. |
| 287 | *ptr = unsafe { ptr.offset(-1) }; |
| 288 | let z = unsafe { **ptr }; |
| 289 | ch = utf8_first_byte(z, 2); |
| 290 | if utf8_is_cont_byte(z) { |
| 291 | // SAFETY: `bytes` produces an UTF-8-like string, |
| 292 | // so the iterator must produce a value here. |
| 293 | *ptr = unsafe { ptr.offset(-1) }; |
| 294 | let y = unsafe { **ptr }; |
| 295 | ch = utf8_first_byte(y, 3); |
| 296 | if utf8_is_cont_byte(y) { |
| 297 | // SAFETY: `bytes` produces an UTF-8-like string, |
| 298 | // so the iterator must produce a value here. |
| 299 | *ptr = unsafe { ptr.offset(-1) }; |
| 300 | let x = unsafe { **ptr }; |
| 301 | ch = utf8_first_byte(x, 4); |
| 302 | ch = utf8_acc_cont_byte(ch, y); |
| 303 | } |
| 304 | ch = utf8_acc_cont_byte(ch, z); |
| 305 | } |
| 306 | ch = utf8_acc_cont_byte(ch, w); |
| 307 | |
| 308 | ch |
| 309 | } |
| 310 | |
| 311 | /// Returns the initial codepoint accumulator for the first byte. |
| 312 | /// The first byte is special, only want bottom 5 bits for width 2, 4 bits |
no test coverage detected