orx_imp_vec/common_traits/
index.rs1use crate::imp_vec::ImpVec;
2use core::ops::{Index, IndexMut};
3use orx_pinned_vec::PinnedVec;
4
5const OOB: &str = "out-of-bounds";
6
7impl<T, P: PinnedVec<T>> Index<usize> for ImpVec<T, P> {
8 type Output = T;
9
10 #[inline(always)]
11 fn index(&self, index: usize) -> &Self::Output {
12 self.get(index).expect(OOB)
13 }
14}
15
16impl<T, P: PinnedVec<T>> IndexMut<usize> for ImpVec<T, P> {
17 #[inline(always)]
18 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
19 self.get_mut(index).expect(OOB)
20 }
21}