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: IdxThe 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)
one_sided_range #69780)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 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)).
1.28.0 (const: unstable) · Source§impl<T> RangeBounds<T> for RangeToInclusive<T>
impl<T> RangeBounds<T> for RangeToInclusive<T>
1.26.0 (const: unstable) · Source§impl<T> SliceIndex<[T]> for RangeToInclusive<usize>
The methods index and index_mut panic if the end of the range is out of bounds.
impl<T> SliceIndex<[T]> for RangeToInclusive<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]>
slice_index_methods)Source§fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>
fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>
slice_index_methods)Source§unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]
unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]
slice_index_methods)Source§unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T]
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T]
slice_index_methods)