pub struct RangeTo<Idx> {
pub end: Idx,
}
new_range_api
#125687)Expand description
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
:
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
.
Fields§
§end: Idx
new_range_api
#125687)The upper bound of the range (exclusive).
Implementations§
Trait Implementations§
1.0.0 · Source§impl<Idx: Eq> Eq for RangeTo<Idx>
impl<Idx: Eq> Eq for RangeTo<Idx>
#[doc(hidden)] fn assert_receiver_is_total_eq(&self)
Source§impl<T> IntoBounds<T> for RangeTo<T>
impl<T> IntoBounds<T> for RangeTo<T>
Source§impl<T> OneSidedRange<T> for RangeTo<T>where
Self: RangeBounds<T>,
impl<T> OneSidedRange<T> for RangeTo<T>where
Self: RangeBounds<T>,
Source§fn bound(self) -> (OneSidedRangeBound, T)
fn bound(self) -> (OneSidedRangeBound, T)
one_sided_range
#69780)split_off
and
split_off_mut
that returns the bound of the one-sided range.1.28.0 · Source§impl<T> RangeBounds<T> for RangeTo<&T>
impl<T> RangeBounds<T> for RangeTo<&T>
1.28.0 · Source§impl<T> RangeBounds<T> for RangeTo<T>
impl<T> RangeBounds<T> for RangeTo<T>
1.15.0 · Source§impl<T> SliceIndex<[T]> for RangeTo<usize>
The methods index
and index_mut
panic if the end of the range is out of bounds.
impl<T> SliceIndex<[T]> for RangeTo<usize>
The methods index
and index_mut
panic if 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
)Source§impl SliceIndex<ByteStr> for RangeTo<usize>
impl SliceIndex<ByteStr> for RangeTo<usize>
Source§fn get(self, slice: &ByteStr) -> Option<&Self::Output>
fn get(self, slice: &ByteStr) -> Option<&Self::Output>
slice_index_methods
)Source§fn get_mut(self, slice: &mut ByteStr) -> Option<&mut Self::Output>
fn get_mut(self, slice: &mut ByteStr) -> Option<&mut Self::Output>
slice_index_methods
)Source§unsafe fn get_unchecked(self, slice: *const ByteStr) -> *const Self::Output
unsafe fn get_unchecked(self, slice: *const ByteStr) -> *const Self::Output
slice_index_methods
)Source§unsafe fn get_unchecked_mut(self, slice: *mut ByteStr) -> *mut Self::Output
unsafe fn get_unchecked_mut(self, slice: *mut ByteStr) -> *mut Self::Output
slice_index_methods
)1.20.0 · Source§impl SliceIndex<str> for RangeTo<usize>
Implements substring slicing with syntax &self[.. end]
or &mut self[.. end]
.
impl SliceIndex<str> for RangeTo<usize>
Implements substring slicing with syntax &self[.. end]
or &mut self[.. end]
.
Returns a slice of the given string from the byte range [0, end
).
Equivalent to &self[0 .. end]
or &mut self[0 .. end]
.
This operation is O(1).
Prior to 1.20.0, these indexing operations were still supported by
direct implementation of Index
and IndexMut
.
§Panics
Panics if end
does not point to the starting byte offset of a
character (as defined by is_char_boundary
), or if end > len
.
Source§fn get(self, slice: &str) -> Option<&Self::Output>
fn get(self, slice: &str) -> Option<&Self::Output>
slice_index_methods
)Source§fn get_mut(self, slice: &mut str) -> Option<&mut Self::Output>
fn get_mut(self, slice: &mut str) -> Option<&mut Self::Output>
slice_index_methods
)Source§unsafe fn get_unchecked(self, slice: *const str) -> *const Self::Output
unsafe fn get_unchecked(self, slice: *const str) -> *const Self::Output
slice_index_methods
)Source§unsafe fn get_unchecked_mut(self, slice: *mut str) -> *mut Self::Output
unsafe fn get_unchecked_mut(self, slice: *mut str) -> *mut Self::Output
slice_index_methods
)impl<Idx: Copy> Copy for RangeTo<Idx>
impl Sealed for RangeTo<usize>
impl<Idx> StructuralPartialEq for RangeTo<Idx>
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)] const IS_ZST: bool = _
#[doc(hidden)] const IS_ZST: bool = _
sized_type_properties
)Source§#[doc(hidden)] const LAYOUT: Layout = _
#[doc(hidden)] const LAYOUT: Layout = _
sized_type_properties
)Source§#[doc(hidden)] const MAX_SLICE_LEN: usize = _
#[doc(hidden)] const MAX_SLICE_LEN: usize = _
sized_type_properties
)[Self]
. Read more