pub struct RangeFrom<Idx> {
pub start: Idx,
}
new_range_api #125687)
A range only bounded inclusively below (start..).
The RangeFrom start.. contains all values with x >= start.
Note: Overflow in the Iterator implementation (when the contained data type reaches its numerical limit) is allowed to panic, wrap, or saturate. This behavior is defined by the implementation of the Step trait. For primitive integers, this follows the normal rules, and respects the overflow checks profile (panic in debug, wrap in release). Note also that overflow happens earlier than you might assume: the overflow happens in the call to next that yields the maximum value, as the range must be set to a state to yield the next value.
The start.. syntax is a RangeFrom:
#![feature(new_range_api)]
use core::range::RangeFrom;
assert_eq!(RangeFrom::from(2..), core::range::RangeFrom { start: 2 });
assert_eq!(2 + 3 + 4, RangeFrom::from(2..).into_iter().take(3).sum());start: Idxnew_range_api #125687)
The lower bound of the range (inclusive).
impl<Idx> RangeFrom<Idx>where
Idx: Step,pub fn iter(&self) -> RangeFromIter<Idx> ⓘ
new_range_api #125687)
Creates an iterator over the elements within this range.
Shorthand for .clone().into_iter()
#![feature(new_range_api)] use core::range::RangeFrom; let mut i = RangeFrom::from(3..).iter().map(|n| n*n); assert_eq!(i.next(), Some(9)); assert_eq!(i.next(), Some(16)); assert_eq!(i.next(), Some(25));
impl<Idx> RangeFrom<Idx>where
Idx: PartialOrd,pub const fn contains<U>(&self, item: &U) -> boolwhere
Idx: PartialOrd<U>,
U: PartialOrd<Idx> + ?Sized,new_range_api #125687)
Returns true if item is contained in the range.
#![feature(new_range_api)] use core::range::RangeFrom; assert!(!RangeFrom::from(3..).contains(&2)); assert!( RangeFrom::from(3..).contains(&3)); assert!( RangeFrom::from(3..).contains(&1_000_000_000)); assert!( RangeFrom::from(0.0..).contains(&0.5)); assert!(!RangeFrom::from(0.0..).contains(&f32::NAN)); assert!(!RangeFrom::from(f32::NAN..).contains(&0.5));
impl<Idx> Clone for RangeFrom<Idx>where
Idx: Clone,fn clone(&self) -> RangeFrom<Idx>
fn clone_from(&mut self, source: &Self)
source. Read more
impl<Idx> Debug for RangeFrom<Idx>where
Idx: Debug,fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>
impl<T> From<RangeFrom<T>> for RangeFrom<T>
fn from(value: RangeFrom<T>) -> RangeFrom<T> ⓘ
impl<T> From<RangeFrom<T>> for RangeFrom<T>
fn from(value: RangeFrom<T>) -> RangeFrom<T>
impl<Idx> Hash for RangeFrom<Idx>where
Idx: Hash,fn hash<__H>(&self, state: &mut __H)where
__H: Hasher,fn hash_slice<H>(data: &[Self], state: &mut H)where
H: Hasher,
Self: Sized,impl<T> IntoBounds<T> for RangeFrom<T>
fn into_bounds(self) -> (Bound<T>, Bound<T>)
range_into_bounds #136903)
(start_bound, end_bound). Read more
fn intersect<R>(self, other: R) -> (Bound<T>, Bound<T>)where
Self: Sized,
T: Ord,
R: IntoBounds<T>,range_into_bounds #136903)
impl<A> IntoIterator for RangeFrom<A>where
A: Step,type Item = A
type IntoIter = RangeFromIter<A>
fn into_iter(self) -> <RangeFrom<A> as IntoIterator>::IntoIter
impl<Idx> PartialEq for RangeFrom<Idx>where
Idx: PartialEq,fn eq(&self, other: &RangeFrom<Idx>) -> bool
self and other values to be equal, and is used by ==.fn ne(&self, other: &Rhs) -> bool
!=. The default implementation is almost always sufficient, and should not be overridden without very good reason.impl<T> RangeBounds<T> for RangeFrom<&T>If you need to use this implementation where T is unsized, consider using the RangeBounds impl for a 2-tuple of Bound<&T>, i.e. replace start.. with (Bound::Included(start), Bound::Unbounded).
fn start_bound(&self) -> Bound<&T>
fn end_bound(&self) -> Bound<&T>
fn contains<U>(&self, item: &U) -> boolwhere
T: PartialOrd<U>,
U: PartialOrd<T> + ?Sized,fn is_empty(&self) -> boolwhere
T: PartialOrd,range_bounds_is_empty #137300)
true if the range contains no items. One-sided ranges (RangeFrom, etc) always return false. Read more
impl<T> RangeBounds<T> for RangeFrom<T>
fn start_bound(&self) -> Bound<&T>
fn end_bound(&self) -> Bound<&T>
fn contains<U>(&self, item: &U) -> boolwhere
T: PartialOrd<U>,
U: PartialOrd<T> + ?Sized,fn is_empty(&self) -> boolwhere
T: PartialOrd,range_bounds_is_empty #137300)
true if the range contains no items. One-sided ranges (RangeFrom, etc) always return false. Read more
impl<T> SliceIndex<[T]> for RangeFrom<usize>
type Output = [T]
fn get(self, slice: &[T]) -> Option<&[T]>
slice_index_methods)
fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>
slice_index_methods)
unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]
slice_index_methods)
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T]
slice_index_methods)
fn index(self, slice: &[T]) -> &[T]
slice_index_methods)
fn index_mut(self, slice: &mut [T]) -> &mut [T]
slice_index_methods)
impl SliceIndex<ByteStr> for RangeFrom<usize>
type Output = ByteStr
fn get(
self,
slice: &ByteStr,
) -> Option<&<RangeFrom<usize> as SliceIndex<ByteStr>>::Output>slice_index_methods)
fn get_mut(
self,
slice: &mut ByteStr,
) -> Option<&mut <RangeFrom<usize> as SliceIndex<ByteStr>>::Output>slice_index_methods)
unsafe fn get_unchecked(
self,
slice: *const ByteStr,
) -> *const <RangeFrom<usize> as SliceIndex<ByteStr>>::Outputslice_index_methods)
unsafe fn get_unchecked_mut(
self,
slice: *mut ByteStr,
) -> *mut <RangeFrom<usize> as SliceIndex<ByteStr>>::Outputslice_index_methods)
fn index(
self,
slice: &ByteStr,
) -> &<RangeFrom<usize> as SliceIndex<ByteStr>>::Outputslice_index_methods)
fn index_mut(
self,
slice: &mut ByteStr,
) -> &mut <RangeFrom<usize> as SliceIndex<ByteStr>>::Outputslice_index_methods)
impl SliceIndex<str> for RangeFrom<usize>
type Output = str
fn get(
self,
slice: &str,
) -> Option<&<RangeFrom<usize> as SliceIndex<str>>::Output>slice_index_methods)
fn get_mut(
self,
slice: &mut str,
) -> Option<&mut <RangeFrom<usize> as SliceIndex<str>>::Output>slice_index_methods)
unsafe fn get_unchecked(
self,
slice: *const str,
) -> *const <RangeFrom<usize> as SliceIndex<str>>::Outputslice_index_methods)
unsafe fn get_unchecked_mut(
self,
slice: *mut str,
) -> *mut <RangeFrom<usize> as SliceIndex<str>>::Outputslice_index_methods)
fn index(self, slice: &str) -> &<RangeFrom<usize> as SliceIndex<str>>::Output
slice_index_methods)
fn index_mut(
self,
slice: &mut str,
) -> &mut <RangeFrom<usize> as SliceIndex<str>>::Outputslice_index_methods)
impl<Idx> Copy for RangeFrom<Idx>where
Idx: Copy,impl<Idx> Eq for RangeFrom<Idx>where
Idx: Eq,impl<Idx> StructuralPartialEq for RangeFrom<Idx>
impl<Idx> Freeze for RangeFrom<Idx>where
Idx: Freeze,impl<Idx> RefUnwindSafe for RangeFrom<Idx>where
Idx: RefUnwindSafe,impl<Idx> Send for RangeFrom<Idx>where
Idx: Send,impl<Idx> Sync for RangeFrom<Idx>where
Idx: Sync,impl<Idx> Unpin for RangeFrom<Idx>where
Idx: Unpin,impl<Idx> UnwindSafe for RangeFrom<Idx>where
Idx: UnwindSafe,impl<T> Any for Twhere
T: 'static + ?Sized,impl<T> Borrow<T> for Twhere
T: ?Sized,impl<T> BorrowMut<T> for Twhere
T: ?Sized,impl<T> CloneToUninit for Twhere
T: Clone,unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit #126799)
impl<T> From<T> for T
fn from(t: T) -> T
Returns the argument unchanged.
impl<T, U> Into<U> for Twhere
U: From<T>,fn into(self) -> U
Calls U::from(self).
That is, this conversion is whatever the implementation of From<T> for U chooses to do.
impl<T> ToOwned for Twhere
T: Clone,type Owned = T
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)
impl<T, U> TryFrom<U> for Twhere
U: Into<T>,type Error = Infallible
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/range/struct.RangeFrom.html