Function
slice_unchecked
(s: &Wtf8, begin: usize, end: usize)
Source from the content-addressed store, hash-verified
| 1331 | /// `begin` and `end` must be within bounds and on codepoint boundaries. |
| 1332 | #[inline] |
| 1333 | pub const unsafe fn slice_unchecked(s: &Wtf8, begin: usize, end: usize) -> &Wtf8 { |
| 1334 | // SAFETY: memory layout of a &[u8] and &Wtf8 are the same |
| 1335 | unsafe { |
| 1336 | let len = end - begin; |
| 1337 | let start = s.as_bytes().as_ptr().add(begin); |
| 1338 | Wtf8::from_bytes_unchecked(slice::from_raw_parts(start, len)) |
| 1339 | } |
| 1340 | } |
| 1341 | |
| 1342 | /// Copied from core::str::raw::slice_error_fail |
| 1343 | #[inline(never)] |
Tested by
no test coverage detected