orx_linked_list/list/common_traits/
index.rs1use crate::{
2 DoublyEnds, DoublyEndsMut, DoublyIdx, List, ListSlice, ListSliceMut, Singly, SinglyEnds,
3 SinglyEndsMut, SinglyIdx, type_aliases::OOB, variant::Doubly,
4};
5use core::ops::{Index, IndexMut};
6use orx_pinned_vec::PinnedVec;
7use orx_selfref_col::{MemoryPolicy, Node};
8
9impl<'i, T, M, P> Index<&'i DoublyIdx<T>> for List<Doubly<T>, M, P>
12where
13 M: MemoryPolicy<Doubly<T>>,
14 P: PinnedVec<Node<Doubly<T>>>,
15{
16 type Output = T;
17
18 fn index(&self, index: &'i DoublyIdx<T>) -> &Self::Output {
26 self.get(index).expect(OOB)
27 }
28}
29
30impl<'i, T, M, P> Index<&'i DoublyIdx<T>> for ListSlice<'_, Doubly<T>, M, P>
31where
32 M: MemoryPolicy<Doubly<T>>,
33 P: PinnedVec<Node<Doubly<T>>>,
34{
35 type Output = T;
36
37 fn index(&self, index: &'i DoublyIdx<T>) -> &Self::Output {
45 self.get(index).expect(OOB)
46 }
47}
48
49impl<'i, T, M, P> Index<&'i DoublyIdx<T>> for ListSliceMut<'_, Doubly<T>, M, P>
50where
51 M: MemoryPolicy<Doubly<T>>,
52 P: PinnedVec<Node<Doubly<T>>>,
53{
54 type Output = T;
55
56 fn index(&self, index: &'i DoublyIdx<T>) -> &Self::Output {
64 self.get(index).expect(OOB)
65 }
66}
67
68impl<'i, T, M, P> IndexMut<&'i DoublyIdx<T>> for List<Doubly<T>, M, P>
69where
70 M: MemoryPolicy<Doubly<T>>,
71 P: PinnedVec<Node<Doubly<T>>>,
72{
73 fn index_mut(&mut self, index: &'i DoublyIdx<T>) -> &mut Self::Output {
81 self.get_mut(index).expect(OOB)
82 }
83}
84
85impl<'i, T, M, P> IndexMut<&'i DoublyIdx<T>> for ListSliceMut<'_, Doubly<T>, M, P>
86where
87 M: MemoryPolicy<Doubly<T>>,
88 P: PinnedVec<Node<Doubly<T>>>,
89{
90 fn index_mut(&mut self, index: &'i DoublyIdx<T>) -> &mut Self::Output {
98 self.get_mut(index).expect(OOB)
99 }
100}
101
102impl<'i, T, M, P> Index<&'i SinglyIdx<T>> for List<Singly<T>, M, P>
105where
106 M: MemoryPolicy<Singly<T>>,
107 P: PinnedVec<Node<Singly<T>>>,
108{
109 type Output = T;
110
111 fn index(&self, index: &'i SinglyIdx<T>) -> &Self::Output {
119 self.get(index).expect(OOB)
120 }
121}
122
123impl<'i, T, M, P> Index<&'i SinglyIdx<T>> for ListSlice<'_, Singly<T>, M, P>
124where
125 M: MemoryPolicy<Singly<T>>,
126 P: PinnedVec<Node<Singly<T>>>,
127{
128 type Output = T;
129
130 fn index(&self, index: &'i SinglyIdx<T>) -> &Self::Output {
138 self.get(index).expect(OOB)
139 }
140}
141
142impl<'i, T, M, P> Index<&'i SinglyIdx<T>> for ListSliceMut<'_, Singly<T>, M, P>
143where
144 M: MemoryPolicy<Singly<T>>,
145 P: PinnedVec<Node<Singly<T>>>,
146{
147 type Output = T;
148
149 fn index(&self, index: &'i SinglyIdx<T>) -> &Self::Output {
157 self.get(index).expect(OOB)
158 }
159}
160
161impl<'i, T, M, P> IndexMut<&'i SinglyIdx<T>> for List<Singly<T>, M, P>
162where
163 M: MemoryPolicy<Singly<T>>,
164 P: PinnedVec<Node<Singly<T>>>,
165{
166 fn index_mut(&mut self, index: &'i SinglyIdx<T>) -> &mut Self::Output {
174 self.get_mut(index).expect(OOB)
175 }
176}
177
178impl<'i, T, M, P> IndexMut<&'i SinglyIdx<T>> for ListSliceMut<'_, Singly<T>, M, P>
179where
180 M: MemoryPolicy<Singly<T>>,
181 P: PinnedVec<Node<Singly<T>>>,
182{
183 fn index_mut(&mut self, index: &'i SinglyIdx<T>) -> &mut Self::Output {
191 self.get_mut(index).expect(OOB)
192 }
193}