Struct RangeToInclusive
struct RangeToInclusive<Idx> { ... }
A range only bounded inclusively above (..=last).
The RangeToInclusive ..=last contains all values with x <= last.
It cannot serve as an Iterator because it doesn't have a starting point.
Examples
The ..=last syntax is a RangeToInclusive:
assert_eq!;
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::range::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 last.
let arr = ;
assert_eq!;
assert_eq!;
assert_eq!; // This is a `RangeToInclusive`
assert_eq!;
assert_eq!;
assert_eq!;
Fields
last: IdxThe upper bound of the range (inclusive)
Implementations
impl<Idx: PartialOrd<Idx>> RangeToInclusive<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!;
impl<Idx> Freeze for RangeToInclusive<Idx>
impl<Idx> RefUnwindSafe for RangeToInclusive<Idx>
impl<Idx> Send for RangeToInclusive<Idx>
impl<Idx> StructuralPartialEq for RangeToInclusive<Idx>
impl<Idx> Sync for RangeToInclusive<Idx>
impl<Idx> Unpin for RangeToInclusive<Idx>
impl<Idx> UnwindSafe for RangeToInclusive<Idx>
impl<Idx: $crate::clone::Clone> Clone for RangeToInclusive<Idx>
fn clone(self: &Self) -> RangeToInclusive<Idx>
impl<Idx: $crate::cmp::Eq> Eq for RangeToInclusive<Idx>
impl<Idx: $crate::cmp::PartialEq> PartialEq for RangeToInclusive<Idx>
fn eq(self: &Self, other: &RangeToInclusive<Idx>) -> bool
impl<Idx: $crate::hash::Hash> Hash for RangeToInclusive<Idx>
fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)
impl<Idx: $crate::marker::Copy> Copy for RangeToInclusive<Idx>
impl<Idx: fmt::Debug> Debug for RangeToInclusive<Idx>
fn fmt(self: &Self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result
impl<T> Any for RangeToInclusive<Idx>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for RangeToInclusive<Idx>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for RangeToInclusive<Idx>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for RangeToInclusive<Idx>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for RangeToInclusive<Idx>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> From for RangeToInclusive<T>
fn from(value: legacy::RangeToInclusive<T>) -> Self
impl<T> IntoBounds for RangeToInclusive<T>
fn into_bounds(self: Self) -> (Bound<T>, Bound<T>)
impl<T> RangeBounds for RangeToInclusive<T>
fn start_bound(self: &Self) -> Bound<&T>fn end_bound(self: &Self) -> Bound<&T>
impl<T> SliceIndex for range::RangeToInclusive<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 RangeToInclusive<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 RangeToInclusive<Idx>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for RangeToInclusive<Idx>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>