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: IdxThe 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.1.28.0 (const: unstable) · Source§impl<T> RangeBounds<T> for RangeTo<&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::Excluded(end)).
impl<T> RangeBounds<T> for RangeTo<&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::Excluded(end)).
1.28.0 (const: unstable) · Source§impl<T> RangeBounds<T> for RangeTo<T>
impl<T> RangeBounds<T> for RangeTo<T>
1.15.0 (const: unstable) · Source§impl<T> SliceIndex<[T]> for RangeTo<usize>
The methods index and index_mut panic if the end of the range is out of bounds.
impl<T> SliceIndex<[T]> for RangeTo<usize>
The methods index and index_mut panic if the end of the range is out of bounds.
Source§fn get(self, slice: &[T]) -> Option<&[T]>
fn get(self, slice: &[T]) -> Option<&[T]>
🔬This is a nightly-only experimental API. (
slice_index_methods)Returns a shared reference to the output at this location, if in
bounds.
Source§fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>
fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>
🔬This is a nightly-only experimental API. (
slice_index_methods)Returns a mutable reference to the output at this location, if in
bounds.
Source§unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]
unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]
🔬This is a nightly-only experimental API. (
slice_index_methods)Returns a pointer to the output at this location, without
performing any bounds checking. Read more
Source§unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T]
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T]
🔬This is a nightly-only experimental API. (
slice_index_methods)Returns a mutable pointer to the output at this location, without
performing any bounds checking. Read more