Struct RangeFrom

pub struct RangeFrom<Idx> { pub start: Idx }

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.

Examples

The start.. syntax is a RangeFrom:

assert_eq!((2..), std::ops::RangeFrom { start: 2 });
assert_eq!(2 + 3 + 4, (2..).take(3).sum());
let arr = [0, 1, 2, 3, 4];
assert_eq!(arr[ ..  ], [0, 1, 2, 3, 4]);
assert_eq!(arr[ .. 3], [0, 1, 2      ]);
assert_eq!(arr[ ..=3], [0, 1, 2, 3   ]);
assert_eq!(arr[1..  ], [   1, 2, 3, 4]); // This is a `RangeFrom`
assert_eq!(arr[1.. 3], [   1, 2      ]);
assert_eq!(arr[1..=3], [   1, 2, 3   ]);

Fields

start: Idx

The lower bound of the range (inclusive).

Implementations

impl<Idx: PartialOrd<Idx>> RangeFrom<Idx>

const fn contains<U>(&self, item: &U) -> bool
where
    Idx: ~const PartialOrd<U>,
    U: ?Sized + ~const PartialOrd<Idx>,

Returns true if item is contained in the range.

Examples

assert!(!(3..).contains(&2));
assert!( (3..).contains(&3));
assert!( (3..).contains(&1_000_000_000));

assert!( (0.0..).contains(&0.5));
assert!(!(0.0..).contains(&f32::NAN));
assert!(!(f32::NAN..).contains(&0.5));

Trait Implementations

impl SliceIndex<ByteStr> for RangeFrom<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::Output
unsafe fn get_unchecked_mut(self, slice: *mut ByteStr) -> *mut Self::Output
fn index(self, slice: &ByteStr) -> &Self::Output
fn index_mut(self, slice: &mut ByteStr) -> &mut Self::Output

impl SliceIndex<str> for RangeFrom<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::Output
unsafe fn get_unchecked_mut(self, slice: *mut str) -> *mut Self::Output
fn index(self, slice: &str) -> &Self::Output
fn index_mut(self, slice: &mut str) -> &mut Self::Output

impl<A: Step> FusedIterator for RangeFrom<A>

impl<A: Step> Iterator for RangeFrom<A>

type Item = A;
fn next(&mut self) -> Option<A>
fn size_hint(&self) -> (usize, Option<usize>)
fn nth(&mut self, n: usize) -> Option<A>

impl<A: TrustedStep> TrustedLen for RangeFrom<A>

impl<Idx: Debug> Debug for RangeFrom<Idx>

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

impl<Idx: Eq> Eq for RangeFrom<Idx>

fn assert_fields_are_eq(&self)

impl<Idx: Hash> Hash for RangeFrom<Idx>

fn hash<__H: Hasher>(&self, state: &mut __H)

impl<Idx: PartialEq> StructuralPartialEq for RangeFrom<Idx>

impl<Idx: ~const Clone> Clone for RangeFrom<Idx>

fn clone(&self) -> RangeFrom<Idx>

impl<Idx: ~const PartialEq> PartialEq for RangeFrom<Idx>

fn eq(&self, other: &RangeFrom<Idx>) -> bool

impl<T> From<RangeFrom<T>> for RangeFrom<T>

fn from(value: RangeFrom<T>) -> Self

impl<T> IntoBounds<T> for RangeFrom<T>

fn into_bounds(self) -> (Bound<T>, Bound<T>)

impl<T> OneSidedRange<T> for RangeFrom<T> where Self: RangeBounds<T>,

fn bound(self) -> (OneSidedRangeBound, T)

impl<T> RangeBounds<T> for RangeFrom<&T>

fn start_bound(&self) -> Bound<&T>
fn end_bound(&self) -> Bound<&T>

impl<T> RangeBounds<T> for RangeFrom<T>

fn start_bound(&self) -> Bound<&T>
fn end_bound(&self) -> Bound<&T>

impl<T> SliceIndex<[T]> for RangeFrom<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 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> UnsafeUnpin for RangeFrom<Idx> where Idx: UnsafeUnpin,

impl<Idx> UnwindSafe for RangeFrom<Idx> where Idx: UnwindSafe,

Blanket Implementations

impl<I> IntoIterator for RangeFrom<Idx> where I: Iterator,

type Item = <I as Iterator>::Item;
type IntoIter = I;
fn into_iter(self) -> I

impl<T> Any for RangeFrom<Idx> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for RangeFrom<Idx> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for RangeFrom<Idx> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for RangeFrom<Idx> where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for RangeFrom<Idx>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for RangeFrom<Idx> where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for RangeFrom<Idx>

impl<T, U> Into<U> for RangeFrom<Idx> where 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, U> TryFrom<U> for RangeFrom<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 RangeFrom<Idx> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>