Forward Iterator::{count,last,nth} for IdxRange random access

This commit is contained in:
oxalica 2023-05-06 21:59:03 +08:00
parent 86eaf53600
commit 665c0cb547

View file

@ -184,6 +184,24 @@ impl<T> Iterator for IdxRange<T> {
fn size_hint(&self) -> (usize, Option<usize>) {
self.range.size_hint()
}
fn count(self) -> usize
where
Self: Sized,
{
self.range.count()
}
fn last(self) -> Option<Self::Item>
where
Self: Sized,
{
self.range.last().map(|raw| Idx::from_raw(raw.into()))
}
fn nth(&mut self, n: usize) -> Option<Self::Item> {
self.range.nth(n).map(|raw| Idx::from_raw(raw.into()))
}
}
impl<T> DoubleEndedIterator for IdxRange<T> {