MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / from_slice_unchecked

Method from_slice_unchecked

crates/data-structures/src/slim_slice.rs:891–901  ·  view source on GitHub ↗

Converts a `&[T]` to the limited version without length checking. SAFETY: `slice.len() <= u32::MAX` must hold.

(slice: &'a [T])

Source from the content-addressed store, hash-verified

889 ///
890 /// SAFETY: `slice.len() <= u32::MAX` must hold.
891 pub(super) const unsafe fn from_slice_unchecked(slice: &'a [T]) -> Self {
892 unsafe {
893 let len = slice.len();
894 let ptr = slice.as_ptr().cast_mut();
895 // SAFETY: `&mut [T]` implies that the pointer is non-null.
896 let raw = SlimRawSlice::from_len_ptr(len, ptr);
897 // SAFETY: Our length invariant is satisfied by the caller.
898 let covariant = PhantomData;
899 Self { raw, covariant }
900 }
901 }
902 }
903
904 impl<T> Deref for SlimSlice<'_, T> {

Callers

nothing calls this directly

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected