pub struct RangeFrom<Idx> {
pub start: Idx,
}new_range_api)Expand description
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:
#![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());Fieldsยง
ยงstart: Idxnew_range_api)The lower bound of the range (inclusive).
Implementationsยง
Sourceยงimpl<Idx> RangeFrom<Idx>where
Idx: Step,
impl<Idx> RangeFrom<Idx>where
Idx: Step,
Sourcepub fn iter(&self) -> IterRangeFrom<Idx> โ
๐ฌThis is a nightly-only experimental API. (new_range_api)
pub fn iter(&self) -> IterRangeFrom<Idx> โ
new_range_api)Creates an iterator over the elements within this range.
Shorthand for .clone().into_iter()
ยงExamples
#![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));Sourceยงimpl<Idx> RangeFrom<Idx>where
Idx: PartialOrd,
impl<Idx> RangeFrom<Idx>where
Idx: PartialOrd,
Sourcepub fn contains<U>(&self, item: &U) -> bool
๐ฌThis is a nightly-only experimental API. (new_range_api)
pub fn contains<U>(&self, item: &U) -> bool
new_range_api)Returns true if item is contained in the range.
ยงExamples
#![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));Trait Implementationsยง
Sourceยงimpl<T> IntoBounds<T> for RangeFrom<T>
impl<T> IntoBounds<T> for RangeFrom<T>
Sourceยงimpl<A> IntoIterator for RangeFrom<A>where
A: Step,
impl<A> IntoIterator for RangeFrom<A>where
A: Step,
Sourceยง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).
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).
Sourceยงimpl<T> RangeBounds<T> for RangeFrom<T>
impl<T> RangeBounds<T> for RangeFrom<T>
Sourceยงimpl<T> SliceIndex<[T]> for RangeFrom<usize>
impl<T> SliceIndex<[T]> for RangeFrom<usize>
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 RangeFrom<usize>
impl SliceIndex<ByteStr> for RangeFrom<usize>
Sourceยงfn get(
self,
slice: &ByteStr,
) -> Option<&<RangeFrom<usize> as SliceIndex<ByteStr>>::Output>
fn get( self, slice: &ByteStr, ) -> Option<&<RangeFrom<usize> as SliceIndex<ByteStr>>::Output>
slice_index_methods)Sourceยงfn get_mut(
self,
slice: &mut ByteStr,
) -> Option<&mut <RangeFrom<usize> as SliceIndex<ByteStr>>::Output>
fn get_mut( self, slice: &mut ByteStr, ) -> Option<&mut <RangeFrom<usize> as SliceIndex<ByteStr>>::Output>
slice_index_methods)Sourceยงunsafe fn get_unchecked(
self,
slice: *const ByteStr,
) -> *const <RangeFrom<usize> as SliceIndex<ByteStr>>::Output
unsafe fn get_unchecked( self, slice: *const ByteStr, ) -> *const <RangeFrom<usize> as SliceIndex<ByteStr>>::Output
slice_index_methods)Sourceยงunsafe fn get_unchecked_mut(
self,
slice: *mut ByteStr,
) -> *mut <RangeFrom<usize> as SliceIndex<ByteStr>>::Output
unsafe fn get_unchecked_mut( self, slice: *mut ByteStr, ) -> *mut <RangeFrom<usize> as SliceIndex<ByteStr>>::Output
slice_index_methods)Sourceยงimpl SliceIndex<str> for RangeFrom<usize>
impl SliceIndex<str> for RangeFrom<usize>
Sourceยงfn get(
self,
slice: &str,
) -> Option<&<RangeFrom<usize> as SliceIndex<str>>::Output>
fn get( self, slice: &str, ) -> Option<&<RangeFrom<usize> as SliceIndex<str>>::Output>
slice_index_methods)Sourceยงfn get_mut(
self,
slice: &mut str,
) -> Option<&mut <RangeFrom<usize> as SliceIndex<str>>::Output>
fn get_mut( self, slice: &mut str, ) -> Option<&mut <RangeFrom<usize> as SliceIndex<str>>::Output>
slice_index_methods)Sourceยงunsafe fn get_unchecked(
self,
slice: *const str,
) -> *const <RangeFrom<usize> as SliceIndex<str>>::Output
unsafe fn get_unchecked( self, slice: *const str, ) -> *const <RangeFrom<usize> as SliceIndex<str>>::Output
slice_index_methods)Sourceยงunsafe fn get_unchecked_mut(
self,
slice: *mut str,
) -> *mut <RangeFrom<usize> as SliceIndex<str>>::Output
unsafe fn get_unchecked_mut( self, slice: *mut str, ) -> *mut <RangeFrom<usize> as SliceIndex<str>>::Output
slice_index_methods)