slice_get_unchecked in std::intrinsics - Rust
Description: Projects to the `index`-th element of `slice_ptr`, as the same kind of pointer as the slice was provided – so `&mut [T] → &mut T`, `&[T] → &T`, `*mut [T] → *mut T`, or `*const [T] → *const T` – without a bounds check.

## slice_get_unchecked

# Function slice_get_unchecked

Source

    pub const unsafe fn slice_get_unchecked<ItemPtr, SlicePtr, T>(
        slice_ptr: SlicePtr,
        index: usize,
    ) -> ItemPtrwhere
        ItemPtr: ChangePointee<[T], Pointee = T, Output = SlicePtr>,

🔬This is a nightly-only experimental API. (`core_intrinsics`)
Expand description

Projects to the `index`-th element of `slice_ptr`, as the same kind of pointer as the slice was provided – so `&mut [T] → &mut T`, `&[T] → &T`, `*mut [T] → *mut T`, or `*const [T] → *const T` – without a bounds check.

This is exposed via `<usize as SliceIndex>::get(_unchecked)(_mut)`, and isn’t intended to be used elsewhere.

Expands in MIR to `{&, &mut, &raw const, &raw mut} (*slice_ptr)[index]`, depending on the types involved, so no backend support is needed.

## §Safety

- `index < PtrMetadata(slice_ptr)`, so the indexing is in-bounds for the slice
- the resulting offsetting is in-bounds of the allocation, which is always the case for references, but needs to be upheld manually for pointers