Struct RangeTo
pub struct RangeTo<Idx> { pub end: Idx }
A range only bounded exclusively above (..end).
The RangeTo ..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 RangeTo:
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::RangeTo<{integer}>:
// std::iter::Iterator` is not satisfied
for i in ..5 {
// ...
}
When used as a slicing index, RangeTo produces a slice of all array
elements before the index indicated by end.
let arr = ;
assert_eq!;
assert_eq!; // This is a `RangeTo`
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Fields
end: IdxThe upper bound of the range (exclusive).
Implementations
impl<Idx: PartialOrd<Idx>> RangeTo<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 RangeTo<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 RangeTo<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: Copy> Copy for RangeTo<Idx>
impl<Idx: Debug> Debug for RangeTo<Idx>
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result
impl<Idx: Eq> Eq for RangeTo<Idx>
fn assert_fields_are_eq(&self)
impl<Idx: Hash> Hash for RangeTo<Idx>
fn hash<__H: Hasher>(&self, state: &mut __H)
impl<Idx: PartialEq> StructuralPartialEq for RangeTo<Idx>
impl<Idx: ~const Clone> Clone for RangeTo<Idx>
fn clone(&self) -> RangeTo<Idx>
impl<Idx: ~const PartialEq> PartialEq for RangeTo<Idx>
fn eq(&self, other: &RangeTo<Idx>) -> bool
impl<T> IntoBounds<T> for RangeTo<T>
fn into_bounds(self) -> (Bound<T>, Bound<T>)
impl<T> OneSidedRange<T> for RangeTo<T>
where
Self: RangeBounds<T>,
fn bound(self) -> (OneSidedRangeBound, T)
impl<T> RangeBounds<T> for RangeTo<&T>
fn start_bound(&self) -> Bound<&T>fn end_bound(&self) -> Bound<&T>
impl<T> RangeBounds<T> for RangeTo<T>
fn start_bound(&self) -> Bound<&T>fn end_bound(&self) -> Bound<&T>
impl<T> SliceIndex<[T]> for RangeTo<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 RangeTo<Idx>
where
Idx: Freeze,
impl<Idx> RefUnwindSafe for RangeTo<Idx>
where
Idx: RefUnwindSafe,
impl<Idx> Send for RangeTo<Idx>
where
Idx: Send,
impl<Idx> Sync for RangeTo<Idx>
where
Idx: Sync,
impl<Idx> Unpin for RangeTo<Idx>
where
Idx: Unpin,
impl<Idx> UnsafeUnpin for RangeTo<Idx>
where
Idx: UnsafeUnpin,
impl<Idx> UnwindSafe for RangeTo<Idx>
where
Idx: UnwindSafe,
Blanket Implementations
impl<T> Any for RangeTo<Idx>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for RangeTo<Idx>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for RangeTo<Idx>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for RangeTo<Idx>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for RangeTo<Idx>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Printable for RangeTo<Idx>
where
T: Copy + Debug,
impl<T> SizeHint for RangeTo<Idx>
where
T: ?Sized,
fn lower_bound(&self) -> usizefn upper_bound(&self) -> Option<usize>
impl<T> SizedTypeProperties for RangeTo<Idx>
impl<T, U> Into<U> for RangeTo<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 RangeTo<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 RangeTo<Idx>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>