(t: &ArrayVec<T, N>)
| 108 | // Helps optimize out some checks in `LengthEncoder::encode`. |
| 109 | #[inline(always)] |
| 110 | fn 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 | |
| 119 | impl<T: Encode, const N: usize> Encoder<ArrayVec<T, N>> for VecEncoder<T> { |
| 120 | #[inline(always)] |