pub struct Range<Idx> {
pub start: Idx,
pub end: Idx,
}
A (half-open) range which is bounded at both ends.
Fields
start | The lower bound of the range (inclusive).
|
end | The upper bound of the range (exclusive).
|
Methods
impl<A> Range<A> where A: Step
Unstable (step_by
#27741): recent addition
Creates an iterator with the same range, but stepping by the
given amount at each iteration.
The resulting iterator handles overflow by stopping.
#![feature(step_by)]
fn main() {
for i in (0..10).step_by(2) {
println!("{}", i);
}
}
#![feature(step_by)]
for i in (0..10).step_by(2) {
println!("{}", i);
}
This prints:
0
2
4
6
8
Trait Implementations
impl<Idx> Debug for Range<Idx> where Idx: Debug
impl<A> Iterator for Range<A> where A: One + Step, &'a A: Add<&'a A>, &'a A::Output == A
type Item = A
fn next(&mut self) -> Option<A>
fn map<B, F>(self, f: F) -> Map<Self, F> where F: FnMut(Self::Item) -> B
fn filter<P>(self, predicate: P) -> Filter<Self, P> where P: FnMut(&Self::Item) -> bool
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where F: FnMut(&mut St, Self::Item) -> Option<B>
fn fuse(self) -> Fuse<Self>
fn inspect<F>(self, f: F) -> Inspect<Self, F> where F: FnMut(&Self::Item) -> ()
fn by_ref(&mut self) -> &mut Self
fn fold<B, F>(self, init: B, f: F) -> B where F: FnMut(B, Self::Item) -> B
fn all<F>(&mut self, f: F) -> bool where F: FnMut(Self::Item) -> bool
fn any<F>(&mut self, f: F) -> bool where F: FnMut(Self::Item) -> bool
fn find<P>(&mut self, predicate: P) -> Option<Self::Item> where P: FnMut(&Self::Item) -> bool
fn max_by<B, F>(self, f: F) -> Option<Self::Item> where F: FnMut(&Self::Item) -> B, B: Ord
fn min_by<B, F>(self, f: F) -> Option<Self::Item> where F: FnMut(&Self::Item) -> B, B: Ord
fn cloned<'a, T>(self) -> Cloned<Self> where T: 'a + Clone, Self: Iterator<Item=&'a T>
fn cycle(self) -> Cycle<Self> where Self: Clone
fn sum<S = Self::Item>(self) -> S where S: Add<Self::Item, Output=S> + Zero
fn product<P = Self::Item>(self) -> P where P: Mul<Self::Item, Output=P> + One
Derived Implementations
impl<Idx> Eq for Range<Idx> where Idx: Eq
impl<Idx> Clone for Range<Idx> where Idx: Clone