MCPcopy Index your code
hub / github.com/RustPython/RustPython / slice_unchecked

Function slice_unchecked

crates/wtf8/src/lib.rs:1333–1340  ·  view source on GitHub ↗
(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]
1333pub 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)]

Callers 2

getMethod · 0.85
indexMethod · 0.85

Calls 3

addMethod · 0.45
as_ptrMethod · 0.45
as_bytesMethod · 0.45

Tested by

no test coverage detected