orx_selfref_col/references/iter/
array_left_most_ptr.rs1use crate::{NodePtr, Variant};
2
3pub struct ArrayLeftMostPtrIter<'a, V: Variant> {
8 iter: core::slice::Iter<'a, Option<NodePtr<V>>>,
9}
10
11impl<'a, V: Variant> ArrayLeftMostPtrIter<'a, V> {
12 pub(crate) fn new(iter: core::slice::Iter<'a, Option<NodePtr<V>>>) -> Self {
13 Self { iter }
14 }
15}
16
17impl<V: Variant> Default for ArrayLeftMostPtrIter<'_, V> {
18 fn default() -> Self {
19 Self {
20 iter: Default::default(),
21 }
22 }
23}
24
25impl<'a, V: Variant> Iterator for ArrayLeftMostPtrIter<'a, V> {
26 type Item = &'a NodePtr<V>;
27
28 #[inline(always)]
29 fn next(&mut self) -> Option<Self::Item> {
30 self.iter.next().and_then(|x| x.as_ref())
31 }
32
33 #[inline(always)]
34 fn size_hint(&self) -> (usize, Option<usize>) {
35 let len = self.iter.len();
36 (len, Some(len))
37 }
38}
39
40impl<V: Variant> ExactSizeIterator for ArrayLeftMostPtrIter<'_, V> {
41 #[inline(always)]
42 fn len(&self) -> usize {
43 self.iter.len()
44 }
45}
46
47impl<V: Variant> DoubleEndedIterator for ArrayLeftMostPtrIter<'_, V> {
48 fn next_back(&mut self) -> Option<Self::Item> {
49 self.iter.next_back().and_then(|x| x.as_ref())
50 }
51}
52
53pub struct ArrayLeftMostPtrIterMut<'a, V: Variant> {
60 iter: core::slice::IterMut<'a, Option<NodePtr<V>>>,
61}
62
63impl<'a, V: Variant> ArrayLeftMostPtrIterMut<'a, V> {
64 pub(crate) fn new(iter: core::slice::IterMut<'a, Option<NodePtr<V>>>) -> Self {
65 Self { iter }
66 }
67}
68
69impl<V: Variant> Default for ArrayLeftMostPtrIterMut<'_, V> {
70 fn default() -> Self {
71 Self {
72 iter: Default::default(),
73 }
74 }
75}
76
77impl<'a, V: Variant> Iterator for ArrayLeftMostPtrIterMut<'a, V> {
78 type Item = &'a mut NodePtr<V>;
79
80 #[inline(always)]
81 fn next(&mut self) -> Option<Self::Item> {
82 self.iter.next().and_then(|x| x.as_mut())
83 }
84
85 #[inline(always)]
86 fn size_hint(&self) -> (usize, Option<usize>) {
87 let len = self.iter.len();
88 (len, Some(len))
89 }
90}
91
92impl<V: Variant> ExactSizeIterator for ArrayLeftMostPtrIterMut<'_, V> {
93 #[inline(always)]
94 fn len(&self) -> usize {
95 self.iter.len()
96 }
97}
98
99impl<V: Variant> DoubleEndedIterator for ArrayLeftMostPtrIterMut<'_, V> {
100 fn next_back(&mut self) -> Option<Self::Item> {
101 self.iter.next_back().and_then(|x| x.as_mut())
102 }
103}