pub struct RangeInclusive<Idx> { /* private fields */ }
Expand description
A range bounded inclusively below and above (start..=end
).
The RangeInclusive
start..=end
contains all values with x >= start
and x <= end
. It is empty unless start <= end
.
This iterator is fused, but the specific values of start
and end
after
iteration has finished are unspecified other than that .is_empty()
will return true
once no more values will be produced.
§Examples
The start..=end
syntax is a RangeInclusive
:
Implementations§
Source§impl<Idx> RangeInclusive<Idx>
impl<Idx> RangeInclusive<Idx>
1.27.0 (const: 1.32.0) · Sourcepub const fn new(start: Idx, end: Idx) -> Self
pub const fn new(start: Idx, end: Idx) -> Self
Creates a new inclusive range. Equivalent to writing start..=end
.
§Examples
1.27.0 (const: 1.32.0) · Sourcepub const fn start(&self) -> &Idx
pub const fn start(&self) -> &Idx
Returns the lower bound of the range (inclusive).
When using an inclusive range for iteration, the values of start()
and
end()
are unspecified after the iteration ended. To determine
whether the inclusive range is empty, use the is_empty()
method
instead of comparing start() > end()
.
Note: the value returned by this method is unspecified after the range has been iterated to exhaustion.
§Examples
1.27.0 (const: 1.32.0) · Sourcepub const fn end(&self) -> &Idx
pub const fn end(&self) -> &Idx
Returns the upper bound of the range (inclusive).
When using an inclusive range for iteration, the values of start()
and end()
are unspecified after the iteration ended. To determine
whether the inclusive range is empty, use the is_empty()
method
instead of comparing start() > end()
.
Note: the value returned by this method is unspecified after the range has been iterated to exhaustion.
§Examples
Trait Implementations§
Source§impl<T> IntoBounds<T> for RangeInclusive<T>
impl<T> IntoBounds<T> for RangeInclusive<T>
1.28.0 · Source§impl<T> RangeBounds<T> for RangeInclusive<&T>
If you need to use this implementation where T
is unsized,
consider using the RangeBounds
impl for a 2-tuple of Bound<&T>
,
i.e. replace start..=end
with (Bound::Included(start), Bound::Included(end))
.
impl<T> RangeBounds<T> for RangeInclusive<&T>
If you need to use this implementation where T
is unsized,
consider using the RangeBounds
impl for a 2-tuple of Bound<&T>
,
i.e. replace start..=end
with (Bound::Included(start), Bound::Included(end))
.