Function presser::read_slice_at_offset_unchecked
source · pub unsafe fn read_slice_at_offset_unchecked<'a, T, S: Slab + ?Sized>(
slab: &'a S,
offset: usize,
len: usize
) -> &'a [T]
Expand description
Reads a &[T]
within slab
at offset
, not checking any requirements.
offset
is the offset, in bytes, after the start ofslab
at which a[T; len]
is placed.len
is the length of the returned slice, counted in elements ofT
.
Safety
You must ensure:
offset
withinslab
is properly aligned forT
offset
is within bounds of theslab
offset + size_of::<T> * len
is within bounds of theslab
- You must have previously fully-initialized a valid* a
[T; len]
at the given offset intoslab
.
* Validity is a complex topic not to be taken lightly. See this rust reference page for more details.
- See also safety docs of
core::slice::from_raw_parts
.