Struct RangeInclusive
struct RangeInclusive<Idx> { ... }
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:
assert_eq!;
assert_eq!;
let arr = ;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!; // This is a `RangeInclusive`
Implementations
impl<Idx> RangeInclusive<Idx>
const fn new(start: Idx, end: Idx) -> SelfCreates a new inclusive range. Equivalent to writing
start..=end.Examples
use RangeInclusive; assert_eq!;const fn start(self: &Self) -> &IdxReturns the lower bound of the range (inclusive).
When using an inclusive range for iteration, the values of
start()andend()are unspecified after the iteration ended. To determine whether the inclusive range is empty, use theis_empty()method instead of comparingstart() > end().Note: the value returned by this method is unspecified after the range has been iterated to exhaustion.
Examples
assert_eq!;const fn end(self: &Self) -> &IdxReturns the upper bound of the range (inclusive).
When using an inclusive range for iteration, the values of
start()andend()are unspecified after the iteration ended. To determine whether the inclusive range is empty, use theis_empty()method instead of comparingstart() > end().Note: the value returned by this method is unspecified after the range has been iterated to exhaustion.
Examples
assert_eq!;const fn into_inner(self: Self) -> (Idx, Idx)Destructures the
RangeInclusiveinto (lower bound, upper (inclusive) bound).Note: the value returned by this method is unspecified after the range has been iterated to exhaustion.
Examples
assert_eq!;
impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx>
const fn contains<U>(self: &Self, item: &U) -> bool where Idx: ~const PartialOrd<U>, U: ?Sized + ~const PartialOrd<Idx>Returns
trueifitemis contained in the range.Examples
assert!; assert!; assert!; assert!; assert!; assert!; assert!; assert!; assert!; assert!; assert!;This method always returns
falseafter iteration has finished:let mut r = 3..=5; assert!; for _ in r.by_ref // Precise field values are unspecified here assert!;const fn is_empty(self: &Self) -> bool where Idx: ~const PartialOrdReturns
trueif the range contains no items.Examples
assert!; assert!; assert!;The range is empty if either side is incomparable:
assert!; assert!; assert!;This method returns
trueafter iteration has finished:let mut r = 3..=5; for _ in r.by_ref // Precise field values are unspecified here assert!;
impl ExactSizeIterator for RangeInclusive<i16>
impl ExactSizeIterator for RangeInclusive<i8>
impl ExactSizeIterator for RangeInclusive<u16>
impl ExactSizeIterator for RangeInclusive<u8>
impl GetDisjointMutIndex for RangeInclusive<usize>
fn is_in_bounds(self: &Self, len: usize) -> boolfn is_overlapping(self: &Self, other: &Self) -> bool
impl SliceIndex for RangeInclusive<usize>
fn get(self: Self, slice: &ByteStr) -> Option<&<Self as >::Output>fn get_mut(self: Self, slice: &mut ByteStr) -> Option<&mut <Self as >::Output>unsafe fn get_unchecked(self: Self, slice: *const ByteStr) -> *const <Self as >::Outputunsafe fn get_unchecked_mut(self: Self, slice: *mut ByteStr) -> *mut <Self as >::Outputfn index(self: Self, slice: &ByteStr) -> &<Self as >::Outputfn index_mut(self: Self, slice: &mut ByteStr) -> &mut <Self as >::Output
impl SliceIndex for RangeInclusive<usize>
fn get(self: Self, slice: &str) -> Option<&<Self as >::Output>fn get_mut(self: Self, slice: &mut str) -> Option<&mut <Self as >::Output>unsafe fn get_unchecked(self: Self, slice: *const str) -> *const <Self as >::Outputunsafe fn get_unchecked_mut(self: Self, slice: *mut str) -> *mut <Self as >::Outputfn index(self: Self, slice: &str) -> &<Self as >::Outputfn index_mut(self: Self, slice: &mut str) -> &mut <Self as >::Output
impl<A: Step> DoubleEndedIterator for RangeInclusive<A>
fn next_back(self: &mut Self) -> Option<A>fn nth_back(self: &mut Self, n: usize) -> Option<A>fn try_rfold<B, F, R>(self: &mut Self, init: B, f: F) -> R where Self: Sized, F: FnMut(B, <Self as >::Item) -> R, R: Try<Output = B>fn rfold<AAA, FFF>(self: Self, init: AAA, fold: FFF) -> AAA where FFF: FnMut(AAA, <Self as >::Item) -> AAA
impl<A: Step> FusedIterator for RangeInclusive<A>
impl<A: Step> Iterator for RangeInclusive<A>
fn next(self: &mut Self) -> Option<A>fn size_hint(self: &Self) -> (usize, Option<usize>)fn count(self: Self) -> usizefn nth(self: &mut Self, n: usize) -> Option<A>fn try_fold<B, F, R>(self: &mut Self, init: B, f: F) -> R where Self: Sized, F: FnMut(B, <Self as >::Item) -> R, R: Try<Output = B>fn fold<AAA, FFF>(self: Self, init: AAA, fold: FFF) -> AAA where FFF: FnMut(AAA, <Self as >::Item) -> AAAfn last(self: Self) -> Option<A>fn min(self: Self) -> Option<A> where A: Ordfn max(self: Self) -> Option<A> where A: Ordfn is_sorted(self: Self) -> bool
impl<A: TrustedStep> TrustedLen for RangeInclusive<A>
impl<I> IntoIterator for RangeInclusive<Idx>
fn into_iter(self: Self) -> I
impl<Idx> Freeze for RangeInclusive<Idx>
impl<Idx> RefUnwindSafe for RangeInclusive<Idx>
impl<Idx> Send for RangeInclusive<Idx>
impl<Idx> StructuralPartialEq for RangeInclusive<Idx>
impl<Idx> Sync for RangeInclusive<Idx>
impl<Idx> Unpin for RangeInclusive<Idx>
impl<Idx> UnsafeUnpin for RangeInclusive<Idx>
impl<Idx> UnwindSafe for RangeInclusive<Idx>
impl<Idx: $crate::clone::Clone> Clone for RangeInclusive<Idx>
fn clone(self: &Self) -> RangeInclusive<Idx>
impl<Idx: $crate::hash::Hash> Hash for RangeInclusive<Idx>
fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)
impl<Idx: fmt::Debug> Debug for RangeInclusive<Idx>
fn fmt(self: &Self, fmt: &mut Formatter<'_>) -> Result
impl<Idx: ~const $crate::cmp::Eq> Eq for RangeInclusive<Idx>
impl<Idx: ~const $crate::cmp::PartialEq> PartialEq for RangeInclusive<Idx>
fn eq(self: &Self, other: &RangeInclusive<Idx>) -> bool
impl<T> Any for RangeInclusive<Idx>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for RangeInclusive<Idx>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for RangeInclusive<Idx>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for RangeInclusive<Idx>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for RangeInclusive<Idx>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> From for RangeInclusive<T>
fn from(value: RangeInclusive<T>) -> Self
impl<T> IntoBounds for RangeInclusive<T>
fn into_bounds(self: Self) -> (Bound<T>, Bound<T>)
impl<T> RangeBounds for RangeInclusive<&T>
fn start_bound(self: &Self) -> Bound<&T>fn end_bound(self: &Self) -> Bound<&T>
impl<T> RangeBounds for RangeInclusive<T>
fn start_bound(self: &Self) -> Bound<&T>fn end_bound(self: &Self) -> Bound<&T>
impl<T> SliceIndex for RangeInclusive<usize>
fn get(self: Self, slice: &[T]) -> Option<&[T]>fn get_mut(self: Self, slice: &mut [T]) -> Option<&mut [T]>unsafe fn get_unchecked(self: Self, slice: *const [T]) -> *const [T]unsafe fn get_unchecked_mut(self: Self, slice: *mut [T]) -> *mut [T]fn index(self: Self, slice: &[T]) -> &[T]fn index_mut(self: Self, slice: &mut [T]) -> &mut [T]
impl<T, U> Into for RangeInclusive<Idx>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for RangeInclusive<Idx>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for RangeInclusive<Idx>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>