pub struct RangeFrom<Idx> {
pub start: Idx,
}
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
:
assert_eq!((2..), std::ops::RangeFrom { start: 2 });
assert_eq!(2 + 3 + 4, (2..).take(3).sum());
Runlet 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 ]);
RunFields
start: Idx
The lower bound of the range (inclusive).
Implementations
sourceimpl<Idx: PartialOrd<Idx>> RangeFrom<Idx>
impl<Idx: PartialOrd<Idx>> RangeFrom<Idx>
1.35.0 · sourcepub fn contains<U>(&self, item: &U) -> boolwhere
Idx: PartialOrd<U>,
U: ?Sized + PartialOrd<Idx>,
pub fn contains<U>(&self, item: &U) -> boolwhere
Idx: PartialOrd<U>,
U: ?Sized + PartialOrd<Idx>,
Trait Implementations
sourceimpl<A: Step> Iterator for RangeFrom<A>
impl<A: Step> Iterator for RangeFrom<A>
type Item = A
type Item = A
sourcefn size_hint(&self) -> (usize, Option<usize>)
fn size_hint(&self) -> (usize, Option<usize>)
sourcefn next_chunk<const N: usize>(
&mut self
) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>where
Self: Sized,
fn next_chunk<const N: usize>(
&mut self
) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>where
Self: Sized,
iter_next_chunk
#98326)N
values. Read moresourcefn count(self) -> usizewhere
Self: Sized,
fn count(self) -> usizewhere
Self: Sized,
sourcefn last(self) -> Option<Self::Item>where
Self: Sized,
fn last(self) -> Option<Self::Item>where
Self: Sized,
sourcefn advance_by(&mut self, n: usize) -> Result<(), usize>
fn advance_by(&mut self, n: usize) -> Result<(), usize>
iter_advance_by
#77404)n
elements. Read more1.28.0 · sourcefn step_by(self, step: usize) -> StepBy<Self> ⓘwhere
Self: Sized,
fn step_by(self, step: usize) -> StepBy<Self> ⓘwhere
Self: Sized,
sourcefn chain<U>(self, other: U) -> Chain<Self, U::IntoIter> ⓘwhere
Self: Sized,
U: IntoIterator<Item = Self::Item>,
fn chain<U>(self, other: U) -> Chain<Self, U::IntoIter> ⓘwhere
Self: Sized,
U: IntoIterator<Item = Self::Item>,
sourcefn zip<U>(self, other: U) -> Zip<Self, U::IntoIter> ⓘwhere
Self: Sized,
U: IntoIterator,
fn zip<U>(self, other: U) -> Zip<Self, U::IntoIter> ⓘwhere
Self: Sized,
U: IntoIterator,
sourcefn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G> ⓘwhere
Self: Sized,
G: FnMut() -> Self::Item,
fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G> ⓘwhere
Self: Sized,
G: FnMut() -> Self::Item,
iter_intersperse
#79524)separator
between adjacent items of the original iterator. Read moresourcefn map<B, F>(self, f: F) -> Map<Self, F> ⓘwhere
Self: Sized,
F: FnMut(Self::Item) -> B,
fn map<B, F>(self, f: F) -> Map<Self, F> ⓘwhere
Self: Sized,
F: FnMut(Self::Item) -> B,
1.21.0 · sourcefn for_each<F>(self, f: F)where
Self: Sized,
F: FnMut(Self::Item),
fn for_each<F>(self, f: F)where
Self: Sized,
F: FnMut(Self::Item),
sourcefn filter<P>(self, predicate: P) -> Filter<Self, P> ⓘwhere
Self: Sized,
P: FnMut(&Self::Item) -> bool,
fn filter<P>(self, predicate: P) -> Filter<Self, P> ⓘwhere
Self: Sized,
P: FnMut(&Self::Item) -> bool,
sourcefn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> ⓘwhere
Self: Sized,
F: FnMut(Self::Item) -> Option<B>,
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> ⓘwhere
Self: Sized,
F: FnMut(Self::Item) -> Option<B>,
sourcefn enumerate(self) -> Enumerate<Self> ⓘwhere
Self: Sized,
fn enumerate(self) -> Enumerate<Self> ⓘwhere
Self: Sized,
sourcefn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> ⓘwhere
Self: Sized,
P: FnMut(&Self::Item) -> bool,
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> ⓘwhere
Self: Sized,
P: FnMut(&Self::Item) -> bool,
sourcefn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> ⓘwhere
Self: Sized,
P: FnMut(&Self::Item) -> bool,
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> ⓘwhere
Self: Sized,
P: FnMut(&Self::Item) -> bool,
1.57.0 · sourcefn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> ⓘwhere
Self: Sized,
P: FnMut(Self::Item) -> Option<B>,
fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> ⓘwhere
Self: Sized,
P: FnMut(Self::Item) -> Option<B>,
sourcefn skip(self, n: usize) -> Skip<Self> ⓘwhere
Self: Sized,
fn skip(self, n: usize) -> Skip<Self> ⓘwhere
Self: Sized,
n
elements. Read moresourcefn take(self, n: usize) -> Take<Self> ⓘwhere
Self: Sized,
fn take(self, n: usize) -> Take<Self> ⓘwhere
Self: Sized,
n
elements, or fewer
if the underlying iterator ends sooner. Read moresourcefn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> ⓘwhere
Self: Sized,
F: FnMut(&mut St, Self::Item) -> Option<B>,
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> ⓘwhere
Self: Sized,
F: FnMut(&mut St, Self::Item) -> Option<B>,
sourcefn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> ⓘwhere
Self: Sized,
U: IntoIterator,
F: FnMut(Self::Item) -> U,
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> ⓘwhere
Self: Sized,
U: IntoIterator,
F: FnMut(Self::Item) -> U,
sourcefn inspect<F>(self, f: F) -> Inspect<Self, F> ⓘwhere
Self: Sized,
F: FnMut(&Self::Item),
fn inspect<F>(self, f: F) -> Inspect<Self, F> ⓘwhere
Self: Sized,
F: FnMut(&Self::Item),
sourcefn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
sourcefn collect<B: FromIterator<Self::Item>>(self) -> Bwhere
Self: Sized,
fn collect<B: FromIterator<Self::Item>>(self) -> Bwhere
Self: Sized,
sourcefn collect_into<E: Extend<Self::Item>>(self, collection: &mut E) -> &mut Ewhere
Self: Sized,
fn collect_into<E: Extend<Self::Item>>(self, collection: &mut E) -> &mut Ewhere
Self: Sized,
iter_collect_into
#94780)sourcefn partition<B, F>(self, f: F) -> (B, B)where
Self: Sized,
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool,
fn partition<B, F>(self, f: F) -> (B, B)where
Self: Sized,
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool,
sourcefn is_partitioned<P>(self, predicate: P) -> boolwhere
Self: Sized,
P: FnMut(Self::Item) -> bool,
fn is_partitioned<P>(self, predicate: P) -> boolwhere
Self: Sized,
P: FnMut(Self::Item) -> bool,
iter_is_partitioned
#62544)true
precede all those that return false
. Read more1.27.0 · sourcefn try_fold<B, F, R>(&mut self, init: B, f: F) -> Rwhere
Self: Sized,
F: FnMut(B, Self::Item) -> R,
R: Try<Output = B>,
fn try_fold<B, F, R>(&mut self, init: B, f: F) -> Rwhere
Self: Sized,
F: FnMut(B, Self::Item) -> R,
R: Try<Output = B>,
1.27.0 · sourcefn try_for_each<F, R>(&mut self, f: F) -> Rwhere
Self: Sized,
F: FnMut(Self::Item) -> R,
R: Try<Output = ()>,
fn try_for_each<F, R>(&mut self, f: F) -> Rwhere
Self: Sized,
F: FnMut(Self::Item) -> R,
R: Try<Output = ()>,
sourcefn fold<B, F>(self, init: B, f: F) -> Bwhere
Self: Sized,
F: FnMut(B, Self::Item) -> B,
fn fold<B, F>(self, init: B, f: F) -> Bwhere
Self: Sized,
F: FnMut(B, Self::Item) -> B,
1.51.0 · sourcefn reduce<F>(self, f: F) -> Option<Self::Item>where
Self: Sized,
F: FnMut(Self::Item, Self::Item) -> Self::Item,
fn reduce<F>(self, f: F) -> Option<Self::Item>where
Self: Sized,
F: FnMut(Self::Item, Self::Item) -> Self::Item,
sourcefn try_reduce<F, R>(
&mut self,
f: F
) -> <<R as Try>::Residual as Residual<Option<R::Output>>>::TryTypewhere
Self: Sized,
F: FnMut(Self::Item, Self::Item) -> R,
R: Try<Output = Self::Item>,
R::Residual: Residual<Option<Self::Item>>,
fn try_reduce<F, R>(
&mut self,
f: F
) -> <<R as Try>::Residual as Residual<Option<R::Output>>>::TryTypewhere
Self: Sized,
F: FnMut(Self::Item, Self::Item) -> R,
R: Try<Output = Self::Item>,
R::Residual: Residual<Option<Self::Item>>,
iterator_try_reduce
#87053)sourcefn all<F>(&mut self, f: F) -> boolwhere
Self: Sized,
F: FnMut(Self::Item) -> bool,
fn all<F>(&mut self, f: F) -> boolwhere
Self: Sized,
F: FnMut(Self::Item) -> bool,
sourcefn any<F>(&mut self, f: F) -> boolwhere
Self: Sized,
F: FnMut(Self::Item) -> bool,
fn any<F>(&mut self, f: F) -> boolwhere
Self: Sized,
F: FnMut(Self::Item) -> bool,
sourcefn find<P>(&mut self, predicate: P) -> Option<Self::Item>where
Self: Sized,
P: FnMut(&Self::Item) -> bool,
fn find<P>(&mut self, predicate: P) -> Option<Self::Item>where
Self: Sized,
P: FnMut(&Self::Item) -> bool,
1.30.0 · sourcefn find_map<B, F>(&mut self, f: F) -> Option<B>where
Self: Sized,
F: FnMut(Self::Item) -> Option<B>,
fn find_map<B, F>(&mut self, f: F) -> Option<B>where
Self: Sized,
F: FnMut(Self::Item) -> Option<B>,
sourcefn try_find<F, R>(
&mut self,
f: F
) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryTypewhere
Self: Sized,
F: FnMut(&Self::Item) -> R,
R: Try<Output = bool>,
R::Residual: Residual<Option<Self::Item>>,
fn try_find<F, R>(
&mut self,
f: F
) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryTypewhere
Self: Sized,
F: FnMut(&Self::Item) -> R,
R: Try<Output = bool>,
R::Residual: Residual<Option<Self::Item>>,
try_find
#63178)sourcefn position<P>(&mut self, predicate: P) -> Option<usize>where
Self: Sized,
P: FnMut(Self::Item) -> bool,
fn position<P>(&mut self, predicate: P) -> Option<usize>where
Self: Sized,
P: FnMut(Self::Item) -> bool,
1.6.0 · sourcefn max_by_key<B: Ord, F>(self, f: F) -> Option<Self::Item>where
Self: Sized,
F: FnMut(&Self::Item) -> B,
fn max_by_key<B: Ord, F>(self, f: F) -> Option<Self::Item>where
Self: Sized,
F: FnMut(&Self::Item) -> B,
1.15.0 · sourcefn max_by<F>(self, compare: F) -> Option<Self::Item>where
Self: Sized,
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
fn max_by<F>(self, compare: F) -> Option<Self::Item>where
Self: Sized,
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.6.0 · sourcefn min_by_key<B: Ord, F>(self, f: F) -> Option<Self::Item>where
Self: Sized,
F: FnMut(&Self::Item) -> B,
fn min_by_key<B: Ord, F>(self, f: F) -> Option<Self::Item>where
Self: Sized,
F: FnMut(&Self::Item) -> B,
1.15.0 · sourcefn min_by<F>(self, compare: F) -> Option<Self::Item>where
Self: Sized,
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
fn min_by<F>(self, compare: F) -> Option<Self::Item>where
Self: Sized,
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
sourcefn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Sized + Iterator<Item = (A, B)>,
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Sized + Iterator<Item = (A, B)>,
1.36.0 · sourcefn copied<'a, T: 'a>(self) -> Copied<Self> ⓘwhere
Self: Sized + Iterator<Item = &'a T>,
T: Copy,
fn copied<'a, T: 'a>(self) -> Copied<Self> ⓘwhere
Self: Sized + Iterator<Item = &'a T>,
T: Copy,
sourcefn cloned<'a, T: 'a>(self) -> Cloned<Self> ⓘwhere
Self: Sized + Iterator<Item = &'a T>,
T: Clone,
fn cloned<'a, T: 'a>(self) -> Cloned<Self> ⓘwhere
Self: Sized + Iterator<Item = &'a T>,
T: Clone,
sourcefn cycle(self) -> Cycle<Self> ⓘwhere
Self: Sized + Clone,
fn cycle(self) -> Cycle<Self> ⓘwhere
Self: Sized + Clone,
sourcefn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N> ⓘwhere
Self: Sized,
fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N> ⓘwhere
Self: Sized,
iter_array_chunks
#100450)N
elements of the iterator at a time. Read more1.11.0 · sourcefn sum<S>(self) -> Swhere
Self: Sized,
S: Sum<Self::Item>,
fn sum<S>(self) -> Swhere
Self: Sized,
S: Sum<Self::Item>,
1.11.0 · sourcefn product<P>(self) -> Pwhere
Self: Sized,
P: Product<Self::Item>,
fn product<P>(self) -> Pwhere
Self: Sized,
P: Product<Self::Item>,
sourcefn cmp_by<I, F>(self, other: I, cmp: F) -> Orderingwhere
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, I::Item) -> Ordering,
fn cmp_by<I, F>(self, other: I, cmp: F) -> Orderingwhere
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, I::Item) -> Ordering,
iter_order_by
#64295)Iterator
with those
of another with respect to the specified comparison function. Read more1.5.0 · sourcefn partial_cmp<I>(self, other: I) -> Option<Ordering>where
I: IntoIterator,
Self::Item: PartialOrd<I::Item>,
Self: Sized,
fn partial_cmp<I>(self, other: I) -> Option<Ordering>where
I: IntoIterator,
Self::Item: PartialOrd<I::Item>,
Self: Sized,
sourcefn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>where
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, I::Item) -> Option<Ordering>,
fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>where
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, I::Item) -> Option<Ordering>,
iter_order_by
#64295)Iterator
with those
of another with respect to the specified comparison function. Read more1.5.0 · sourcefn eq<I>(self, other: I) -> boolwhere
I: IntoIterator,
Self::Item: PartialEq<I::Item>,
Self: Sized,
fn eq<I>(self, other: I) -> boolwhere
I: IntoIterator,
Self::Item: PartialEq<I::Item>,
Self: Sized,
sourcefn eq_by<I, F>(self, other: I, eq: F) -> boolwhere
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, I::Item) -> bool,
fn eq_by<I, F>(self, other: I, eq: F) -> boolwhere
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, I::Item) -> bool,
iter_order_by
#64295)1.5.0 · sourcefn ne<I>(self, other: I) -> boolwhere
I: IntoIterator,
Self::Item: PartialEq<I::Item>,
Self: Sized,
fn ne<I>(self, other: I) -> boolwhere
I: IntoIterator,
Self::Item: PartialEq<I::Item>,
Self: Sized,
1.5.0 · sourcefn lt<I>(self, other: I) -> boolwhere
I: IntoIterator,
Self::Item: PartialOrd<I::Item>,
Self: Sized,
fn lt<I>(self, other: I) -> boolwhere
I: IntoIterator,
Self::Item: PartialOrd<I::Item>,
Self: Sized,
Iterator
are lexicographically
less than those of another. Read more1.5.0 · sourcefn le<I>(self, other: I) -> boolwhere
I: IntoIterator,
Self::Item: PartialOrd<I::Item>,
Self: Sized,
fn le<I>(self, other: I) -> boolwhere
I: IntoIterator,
Self::Item: PartialOrd<I::Item>,
Self: Sized,
Iterator
are lexicographically
less or equal to those of another. Read more1.5.0 · sourcefn gt<I>(self, other: I) -> boolwhere
I: IntoIterator,
Self::Item: PartialOrd<I::Item>,
Self: Sized,
fn gt<I>(self, other: I) -> boolwhere
I: IntoIterator,
Self::Item: PartialOrd<I::Item>,
Self: Sized,
Iterator
are lexicographically
greater than those of another. Read more1.5.0 · sourcefn ge<I>(self, other: I) -> boolwhere
I: IntoIterator,
Self::Item: PartialOrd<I::Item>,
Self: Sized,
fn ge<I>(self, other: I) -> boolwhere
I: IntoIterator,
Self::Item: PartialOrd<I::Item>,
Self: Sized,
Iterator
are lexicographically
greater than or equal to those of another. Read moresourcefn is_sorted_by<F>(self, compare: F) -> boolwhere
Self: Sized,
F: FnMut(&Self::Item, &Self::Item) -> Option<Ordering>,
fn is_sorted_by<F>(self, compare: F) -> boolwhere
Self: Sized,
F: FnMut(&Self::Item, &Self::Item) -> Option<Ordering>,
is_sorted
#53485)sourcefn is_sorted_by_key<F, K>(self, f: F) -> boolwhere
Self: Sized,
F: FnMut(Self::Item) -> K,
K: PartialOrd,
fn is_sorted_by_key<F, K>(self, f: F) -> boolwhere
Self: Sized,
F: FnMut(Self::Item) -> K,
K: PartialOrd,
is_sorted
#53485)sourceimpl<Idx: PartialEq> PartialEq<RangeFrom<Idx>> for RangeFrom<Idx>
impl<Idx: PartialEq> PartialEq<RangeFrom<Idx>> for RangeFrom<Idx>
1.28.0 · sourceimpl<T> RangeBounds<T> for RangeFrom<&T>
impl<T> RangeBounds<T> for RangeFrom<&T>
1.28.0 · sourceimpl<T> RangeBounds<T> for RangeFrom<T>
impl<T> RangeBounds<T> for RangeFrom<T>
1.15.0 (const: unstable) · sourceimpl<T> SliceIndex<[T]> for RangeFrom<usize>
impl<T> SliceIndex<[T]> for RangeFrom<usize>
const: unstable · sourcefn get(self, slice: &[T]) -> Option<&[T]>
fn get(self, slice: &[T]) -> Option<&[T]>
slice_index_methods
)const: unstable · sourcefn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>
fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>
slice_index_methods
)const: unstable · sourceunsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]
unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]
slice_index_methods
)slice
pointer
is undefined behavior even if the resulting reference is not used. Read moreconst: unstable · sourceunsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T]
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T]
slice_index_methods
)slice
pointer
is undefined behavior even if the resulting reference is not used. Read more1.20.0 (const: unstable) · sourceimpl SliceIndex<str> for RangeFrom<usize>
impl SliceIndex<str> for RangeFrom<usize>
Implements substring slicing with syntax &self[begin ..]
or &mut self[begin ..]
.
Returns a slice of the given string from the byte range [begin
, len
).
Equivalent to &self[begin .. len]
or &mut self[begin .. len]
.
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 begin
does not point to the starting byte offset of
a character (as defined by is_char_boundary
), or if begin > len
.
const: unstable · sourcefn get(self, slice: &str) -> Option<&Self::Output>
fn get(self, slice: &str) -> Option<&Self::Output>
slice_index_methods
)const: unstable · sourcefn get_mut(self, slice: &mut str) -> Option<&mut Self::Output>
fn get_mut(self, slice: &mut str) -> Option<&mut Self::Output>
slice_index_methods
)const: unstable · sourceunsafe fn get_unchecked(self, slice: *const str) -> *const Self::Output
unsafe fn get_unchecked(self, slice: *const str) -> *const Self::Output
slice_index_methods
)slice
pointer
is undefined behavior even if the resulting reference is not used. Read moreconst: unstable · sourceunsafe 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
)slice
pointer
is undefined behavior even if the resulting reference is not used. Read more