pub struct Range<Idx> {
pub start: Idx,
pub end: Idx,
}Expand description
A (half-open) range bounded inclusively below and exclusively above
(start..end).
The range start..end contains all values with start <= x < end.
It is empty if start >= end.
ยงExamples
The start..end syntax is a Range:
Fieldsยง
ยงstart: IdxThe lower bound of the range (inclusive).
end: IdxThe upper bound of the range (exclusive).
Implementationsยง
Sourceยงimpl<Idx> Range<Idx>where
Idx: PartialOrd,
impl<Idx> Range<Idx>where
Idx: PartialOrd,
1.35.0 (const: unstable) ยท Sourcepub fn contains<U>(&self, item: &U) -> bool
pub fn contains<U>(&self, item: &U) -> bool
Returns true if item is contained in the range.
ยงExamples
assert!(!(3..5).contains(&2));
assert!( (3..5).contains(&3));
assert!( (3..5).contains(&4));
assert!(!(3..5).contains(&5));
assert!(!(3..3).contains(&3));
assert!(!(3..2).contains(&3));
assert!( (0.0..1.0).contains(&0.5));
assert!(!(0.0..1.0).contains(&f32::NAN));
assert!(!(0.0..f32::NAN).contains(&0.5));
assert!(!(f32::NAN..1.0).contains(&0.5));1.47.0 (const: unstable) ยท Sourcepub fn is_empty(&self) -> boolwhere
Idx: PartialOrd,
pub fn is_empty(&self) -> boolwhere
Idx: PartialOrd,
Returns true if the range contains no items.
ยงExamples
The range is empty if either side is incomparable:
Trait Implementationsยง
impl<T> CloneFromCell for Range<T>where
T: CloneFromCell,
1.0.0 ยท Sourceยงimpl<A> DoubleEndedIterator for Range<A>where
A: Step,
impl<A> DoubleEndedIterator for Range<A>where
A: Step,
Sourceยงfn next_back(&mut self) -> Option<A>
fn next_back(&mut self) -> Option<A>
Removes and returns an element from the end of the iterator. Read more
Sourceยงfn nth_back(&mut self, n: usize) -> Option<A>
fn nth_back(&mut self, n: usize) -> Option<A>
Returns the
nth element from the end of the iterator. Read moreSourceยงfn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>>
fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>>
๐ฌThis is a nightly-only experimental API. (
iter_advance_by #77404)Advances the iterator from the back by
n elements. Read moreSourceยงfn next_chunk_back<const N: usize>(
&mut self,
) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>where
Self: Sized,
fn next_chunk_back<const N: usize>(
&mut self,
) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>where
Self: Sized,
๐ฌThis is a nightly-only experimental API. (
iter_next_chunk #98326)Advances from the back of the iterator and returns an array containing the next
N values in sequence. Read more1.27.0 (const: unstable) ยท Sourceยงfn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R
fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R
This is the reverse version of
Iterator::try_fold(): it takes
elements starting from the back of the iterator. Read more