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
1.27.0 (const: unstable) · Sourcepub fn into_inner(self) -> (Idx, Idx)
pub fn into_inner(self) -> (Idx, Idx)
Destructures the RangeInclusive into (lower bound, upper (inclusive) bound).
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 (const: unstable) · 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)).
1.28.0 (const: unstable) · Source§impl<T> RangeBounds<T> for RangeInclusive<T>
impl<T> RangeBounds<T> for RangeInclusive<T>
1.26.0 (const: unstable) · Source§impl<T> SliceIndex<[T]> for RangeInclusive<usize>
The methods index and index_mut panic if:
impl<T> SliceIndex<[T]> for RangeInclusive<usize>
The methods index and index_mut panic if:
- the end of the range is
usize::MAXor - the start of the range is greater than the end of the range or
- 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)