Struct RangeToInclusive
pub struct RangeToInclusive<Idx> { pub end: Idx }
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:
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::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.
let arr = ;
assert_eq!;
assert_eq!;
assert_eq!; // This is a `RangeToInclusive`
assert_eq!;
assert_eq!;
assert_eq!;
Fields
end: IdxThe upper bound of the range (inclusive)
Implementations
impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx>
const fn contains<U>(&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!;
Trait Implementations
impl SliceIndex<ByteStr> for RangeToInclusive<usize>
type Output = ByteStr;fn get(self, slice: &ByteStr) -> Option<&Self::Output>fn get_mut(self, slice: &mut ByteStr) -> Option<&mut Self::Output>unsafe fn get_unchecked(self, slice: *const ByteStr) -> *const Self::Outputunsafe fn get_unchecked_mut(self, slice: *mut ByteStr) -> *mut Self::Outputfn index(self, slice: &ByteStr) -> &Self::Outputfn index_mut(self, slice: &mut ByteStr) -> &mut Self::Output
impl SliceIndex<str> for RangeToInclusive<usize>
type Output = str;fn get(self, slice: &str) -> Option<&Self::Output>fn get_mut(self, slice: &mut str) -> Option<&mut Self::Output>unsafe fn get_unchecked(self, slice: *const str) -> *const Self::Outputunsafe fn get_unchecked_mut(self, slice: *mut str) -> *mut Self::Outputfn index(self, slice: &str) -> &Self::Outputfn index_mut(self, slice: &mut str) -> &mut Self::Output
impl<Idx: Clone> Clone for RangeToInclusive<Idx>
fn clone(&self) -> RangeToInclusive<Idx>
impl<Idx: Copy> Copy for RangeToInclusive<Idx>
impl<Idx: Debug> Debug for RangeToInclusive<Idx>
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result
impl<Idx: Eq> Eq for RangeToInclusive<Idx>
fn assert_fields_are_eq(&self)
impl<Idx: Hash> Hash for RangeToInclusive<Idx>
fn hash<__H: Hasher>(&self, state: &mut __H)
impl<Idx: PartialEq> PartialEq for RangeToInclusive<Idx>
fn eq(&self, other: &RangeToInclusive<Idx>) -> bool
impl<Idx: PartialEq> StructuralPartialEq for RangeToInclusive<Idx>
impl<T> From<RangeToInclusive<T>> for RangeToInclusive<T>
fn from(value: RangeToInclusive<T>) -> Self
impl<T> IntoBounds<T> for RangeToInclusive<T>
fn into_bounds(self) -> (Bound<T>, Bound<T>)
impl<T> OneSidedRange<T> for RangeToInclusive<T>
where
Self: RangeBounds<T>,
fn bound(self) -> (OneSidedRangeBound, T)
impl<T> RangeBounds<T> for RangeToInclusive<&T>
fn start_bound(&self) -> Bound<&T>fn end_bound(&self) -> Bound<&T>
impl<T> RangeBounds<T> for RangeToInclusive<T>
fn start_bound(&self) -> Bound<&T>fn end_bound(&self) -> Bound<&T>
impl<T> SliceIndex<[T]> for RangeToInclusive<usize>
type Output = [T];fn get(self, slice: &[T]) -> Option<&[T]>fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T]fn index(self, slice: &[T]) -> &[T]fn index_mut(self, slice: &mut [T]) -> &mut [T]
Auto Trait Implementations
impl<Idx> Freeze for RangeToInclusive<Idx>
where
Idx: Freeze,
impl<Idx> RefUnwindSafe for RangeToInclusive<Idx>
where
Idx: RefUnwindSafe,
impl<Idx> Send for RangeToInclusive<Idx>
where
Idx: Send,
impl<Idx> Sync for RangeToInclusive<Idx>
where
Idx: Sync,
impl<Idx> Unpin for RangeToInclusive<Idx>
where
Idx: Unpin,
impl<Idx> UnsafeUnpin for RangeToInclusive<Idx>
where
Idx: UnsafeUnpin,
impl<Idx> UnwindSafe for RangeToInclusive<Idx>
where
Idx: UnwindSafe,
Blanket Implementations
impl<T> Any for RangeToInclusive<Idx>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for RangeToInclusive<Idx>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for RangeToInclusive<Idx>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for RangeToInclusive<Idx>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for RangeToInclusive<Idx>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Printable for RangeToInclusive<Idx>
where
T: Copy + Debug,
impl<T> SizeHint for RangeToInclusive<Idx>
where
T: ?Sized,
fn lower_bound(&self) -> usizefn upper_bound(&self) -> Option<usize>
impl<T> SizedTypeProperties for RangeToInclusive<Idx>
impl<T, U> Into<U> for RangeToInclusive<Idx>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for RangeToInclusive<Idx>
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for RangeToInclusive<Idx>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>