replace LimitedQueueIter with type alias
This commit is contained in:
+3
-25
@@ -58,14 +58,11 @@ impl<T> LimitedQueue<T> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn iter(&self) -> LimitedQueueIter<'_, T> {
|
pub(crate) fn iter(&self) -> LimitedQueueIter<'_, T> {
|
||||||
let iter = self
|
self.queue
|
||||||
.queue
|
|
||||||
.iter()
|
.iter()
|
||||||
.cycle()
|
.cycle()
|
||||||
.skip(self.start)
|
.skip(self.start)
|
||||||
.take(self.queue.len());
|
.take(self.queue.len())
|
||||||
|
|
||||||
LimitedQueueIter { iter }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,23 +88,4 @@ impl<T> Index<usize> for LimitedQueue<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: replace with simple type definition
|
pub(crate) type LimitedQueueIter<'a, T> = Take<Skip<Cycle<Iter<'a, T>>>>;
|
||||||
pub(crate) struct LimitedQueueIter<'a, T> {
|
|
||||||
iter: Take<Skip<Cycle<Iter<'a, T>>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, T> Iterator for LimitedQueueIter<'a, T> {
|
|
||||||
type Item = &'a T;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
|
||||||
self.iter.next()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
|
||||||
self.iter.size_hint()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, T> ExactSizeIterator for LimitedQueueIter<'a, T> {}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user