RangeFrom in std::range - Rust (original) (raw)

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 Steptrait. 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)

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)

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§

Source§

Source§

Converts to this type from the input type.

Source§

Source§

Converts to this type from the input type.

Source§

Source§

Source§

🔬This is a nightly-only experimental API. (range_into_bounds #136903)

Convert this range into the start and end bounds. Returns (start_bound, end_bound). Read more

Source§

Source§

The type of the elements being iterated over.

Source§

Which kind of iterator are we turning this into?

Source§

Creates an iterator from a value. Read more

Source§

Source§

Tests for self and other values to be equal, and is used by ==.

1.0.0 · Source§

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Source§

Source§

Source§

Source§

The output type returned by methods.

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§

🔬This is a nightly-only experimental API. (slice_index_methods)

Returns a shared reference to the output at this location, panicking if out of bounds.

Source§

🔬This is a nightly-only experimental API. (slice_index_methods)

Returns a mutable reference to the output at this location, panicking if out of bounds.

Source§

Source§

The output type returned by methods.

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§

🔬This is a nightly-only experimental API. (slice_index_methods)

Returns a shared reference to the output at this location, panicking if out of bounds.

Source§

🔬This is a nightly-only experimental API. (slice_index_methods)

Returns a mutable reference to the output at this location, panicking if out of bounds.

Source§

Source§

Source§