MCPcopy Create free account
hub / github.com/SoftbearStudios/bitcode / as_slice_assert_len

Function as_slice_assert_len

src/ext/arrayvec.rs:110–117  ·  view source on GitHub ↗
(t: &ArrayVec<T, N>)

Source from the content-addressed store, hash-verified

108// Helps optimize out some checks in `LengthEncoder::encode`.
109#[inline(always)]
110fn as_slice_assert_len<T, const N: usize>(t: &ArrayVec<T, N>) -> &[T] {
111 let s = t.as_slice();
112 // Safety: ArrayVec<N> has length <= N. TODO replace with LengthDecoder<N>.
113 if s.len() > N {
114 unsafe { std::hint::unreachable_unchecked() };
115 }
116 s
117}
118
119impl<T: Encode, const N: usize> Encoder<ArrayVec<T, N>> for VecEncoder<T> {
120 #[inline(always)]

Callers 1

encodeMethod · 0.85

Calls 2

as_sliceMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected