pub struct RangeFrom<Idx> {
pub start: Idx,
}🔬This is a nightly-only experimental API. (new_range_api #125687)
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());🔬This is a nightly-only experimental API. (new_range_api #125687)
The lower bound of the range (inclusive).
Source§
Source 🔬This is a nightly-only experimental API. (new_range_api #125687)
new_range_api #125687)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§
Source 🔬This is a nightly-only experimental API. (new_range_api #125687)
new_range_api #125687)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));Source§
Source§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).
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§
Source§
🔬This is a nightly-only experimental API. (slice_index_methods)
Returns a shared reference to the output at this location, if in bounds.
Source§
🔬This is a nightly-only experimental API. (slice_index_methods)
Returns a mutable reference to the output at this location, if in bounds.
Source§
🔬This is a nightly-only experimental API. (slice_index_methods)
Returns a pointer to the output at this location, without performing any bounds checking. Read more
Source§
🔬This is a nightly-only experimental API. (slice_index_methods)
Returns a mutable pointer to the output at this location, without performing any bounds checking. Read more
Source§
Source§
🔬This is a nightly-only experimental API. (slice_index_methods)
Returns a shared reference to the output at this location, if in bounds.
Source§
🔬This is a nightly-only experimental API. (slice_index_methods)
Returns a mutable reference to the output at this location, if in bounds.
Source§
🔬This is a nightly-only experimental API. (slice_index_methods)
Returns a pointer to the output at this location, without performing any bounds checking. Read more
Source§
🔬This is a nightly-only experimental API. (slice_index_methods)
Returns a mutable pointer to the output at this location, without performing any bounds checking. Read more
Source§
Source§
🔬This is a nightly-only experimental API. (slice_index_methods)
Returns a shared reference to the output at this location, if in bounds.
Source§
🔬This is a nightly-only experimental API. (slice_index_methods)
Returns a mutable reference to the output at this location, if in bounds.
Source§
🔬This is a nightly-only experimental API. (slice_index_methods)
Returns a pointer to the output at this location, without performing any bounds checking. Read more
Source§
🔬This is a nightly-only experimental API. (slice_index_methods)
Returns a mutable pointer to the output at this location, without performing any bounds checking. Read more