pub struct RangeToInclusive<Idx> {
pub end: Idx,
}
Expand description
A range only bounded inclusively above (..=end
).
The RangeToInclusive
..=end
contains all values with x <= end
.
It cannot serve as an Iterator
because it doesn’t have a starting point.
§Examples
The ..=end
syntax is a RangeToInclusive
:
It does not have an IntoIterator
implementation, so you can’t use it in a
for
loop directly. This won’t compile:
ⓘ
// error[E0277]: the trait bound `std::ops::RangeToInclusive<{integer}>:
// std::iter::Iterator` is not satisfied
for i in ..=5 {
// ...
}
When used as a slicing index, RangeToInclusive
produces a slice of all
array elements up to and including the index indicated by end
.
Fields§
§end: Idx
The upper bound of the range (inclusive)
Trait Implementations§
Source§impl<T> IntoBounds<T> for RangeToInclusive<T>
impl<T> IntoBounds<T> for RangeToInclusive<T>
Source§impl<T> OneSidedRange<T> for RangeToInclusive<T>where
Self: RangeBounds<T>,
impl<T> OneSidedRange<T> for RangeToInclusive<T>where
Self: RangeBounds<T>,
Source§fn bound(self) -> (OneSidedRangeBound, T)
fn bound(self) -> (OneSidedRangeBound, T)
🔬This is a nightly-only experimental API. (
one_sided_range
#69780)An internal-only helper function for
split_off
and
split_off_mut
that returns the bound of the one-sided range.1.28.0 · Source§impl<T> RangeBounds<T> for RangeToInclusive<&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 ..=end
with (Bound::Unbounded, Bound::Included(end))
.
impl<T> RangeBounds<T> for RangeToInclusive<&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 ..=end
with (Bound::Unbounded, Bound::Included(end))
.