There is a weak convention in the ecosystem that `IterFoos` is an iterator yielding items of type `Foo` (e.g. `bitflags` `IterNames`, `hashbrown` `IterBuckets`), while `FooIter` is an iterator over `Foo` from an `.iter()` or `.into_iter()` method (e.g. `memchr` `OneIter`, `regex` `SetMatchesIter`). Rename `IterRange`, `IterRangeInclusive`, and `IterRangeFrom` to `RangeIter`, `RangeInclusiveIter`, and `RangeInclusiveIter` to match this. Tracking issue: RUST-125687 (`new_range_api`)
23 lines
590 B
Rust
23 lines
590 B
Rust
//@ run-pass
|
|
//@ compile-flags: -C overflow-checks=yes
|
|
|
|
#![feature(new_range_api)]
|
|
|
|
use std::{iter, range};
|
|
|
|
fn main() {
|
|
for (a, b) in iter::zip(0_u32..256, range::RangeFrom::from(0_u8..)) {
|
|
assert_eq!(a, u32::from(b));
|
|
}
|
|
|
|
let mut a = range::RangeFrom::from(0_u8..).into_iter();
|
|
let mut b = 0_u8..;
|
|
assert_eq!(a.next(), b.next());
|
|
assert_eq!(a.nth(5), b.nth(5));
|
|
assert_eq!(a.nth(0), b.next());
|
|
|
|
let mut a = range::RangeFrom::from(0_u8..).into_iter();
|
|
let mut b = 0_u8..;
|
|
assert_eq!(a.nth(5), b.nth(5));
|
|
assert_eq!(a.nth(0), b.next());
|
|
}
|