pub struct RangeTo<Idx> {
pub end: Idx,
}
Expand description
A range only bounded exclusively above (..end
).
The RangeTo
..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 RangeTo
:
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::RangeTo<{integer}>:
// std::iter::Iterator` is not satisfied
for i in ..5 {
// ...
}
When used as a slicing index, RangeTo
produces a slice of all array
elements before the index indicated by end
.
Fields§
§end: Idx
The upper bound of the range (exclusive).
Trait Implementations§
Source§impl<T> IntoBounds<T> for RangeTo<T>
impl<T> IntoBounds<T> for RangeTo<T>
Source§impl<T> OneSidedRange<T> for RangeTo<T>where
Self: RangeBounds<T>,
impl<T> OneSidedRange<T> for RangeTo<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.