aboutsummaryrefslogtreecommitdiffstats
path: root/components/range/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/range/lib.rs')
-rw-r--r--components/range/lib.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/components/range/lib.rs b/components/range/lib.rs
index 8c5ca095f53..24c7231946c 100644
--- a/components/range/lib.rs
+++ b/components/range/lib.rs
@@ -193,6 +193,19 @@ impl<I: RangeIndex> Iterator for EachIndex<I> {
}
}
+impl<I: RangeIndex> DoubleEndedIterator for EachIndex<I> {
+ #[inline]
+ fn next_back(&mut self) -> Option<Self::Item> {
+ if self.start < self.stop {
+ let next = self.stop - I::one();
+ self.stop = next;
+ Some(next)
+ } else {
+ None
+ }
+ }
+}
+
impl<I: RangeIndex> Range<I> {
/// Create a new range from beginning and length offsets. This could be
/// denoted as `[begin, begin + length)`.