mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 06:03:58 +00:00
Forward Iterator::{count,last,nth}
for IdxRange
random access
This commit is contained in:
parent
86eaf53600
commit
665c0cb547
1 changed files with 18 additions and 0 deletions
|
@ -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> {
|
||||
|
|
Loading…
Reference in a new issue