Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 665c0cb

Browse files
committed
Forward Iterator::{count,last,nth} for IdxRange random access
1 parent 86eaf53 commit 665c0cb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/la-arena/src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,24 @@ impl<T> Iterator for IdxRange<T> {
184184
fn size_hint(&self) -> (usize, Option<usize>) {
185185
self.range.size_hint()
186186
}
187+
188+
fn count(self) -> usize
189+
where
190+
Self: Sized,
191+
{
192+
self.range.count()
193+
}
194+
195+
fn last(self) -> Option<Self::Item>
196+
where
197+
Self: Sized,
198+
{
199+
self.range.last().map(|raw| Idx::from_raw(raw.into()))
200+
}
201+
202+
fn nth(&mut self, n: usize) -> Option<Self::Item> {
203+
self.range.nth(n).map(|raw| Idx::from_raw(raw.into()))
204+
}
187205
}
188206

189207
impl<T> DoubleEndedIterator for IdxRange<T> {

0 commit comments

Comments
 (0)