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

🔬This is a nightly-only experimental API. (new_range_api #125687)

Expand description

§Experimental replacement range types

The types within this module are meant to replace the existingRange, RangeInclusive, and RangeFrom types in a future edition.

#![feature(new_range_api)]
use core::range::{Range, RangeFrom, RangeInclusive};

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[     RangeFrom::from(1..  )], [   1, 2, 3, 4]);
assert_eq!(arr[         Range::from(1..3 )], [   1, 2      ]);
assert_eq!(arr[RangeInclusive::from(1..=3)], [   1, 2, 3   ]);

legacyExperimental

Legacy range types

IterRangeExperimental

By-value Range iterator.

IterRangeFromExperimental

By-value RangeFrom iterator.

IterRangeInclusiveExperimental

By-value RangeInclusive iterator.

RangeExperimental

A (half-open) range bounded inclusively below and exclusively above (start..end in a future edition).

RangeFromExperimental

A range only bounded inclusively below (start..).

RangeFullExperimental

An unbounded range (..).

RangeInclusiveExperimental

A range bounded inclusively below and above (start..=end).

RangeToExperimental

A range only bounded exclusively above (..end).

RangeToInclusiveExperimental

A range only bounded inclusively above (..=end).

BoundExperimental

An endpoint of a range of keys.

IntoBoundsExperimental

Used to convert a range into start and end bounds, consuming the range by value.

OneSidedRangeExperimental

OneSidedRange is implemented for built-in range types that are unbounded on one side. For example, a.., ..b and ..=c implement OneSidedRange, but .., d..e, and f..=g do not.

RangeBoundsExperimental

RangeBounds is implemented by Rust’s built-in range types, produced by range syntax like .., a.., ..b, ..=c, d..e, or f..=g.

StepExperimental

Objects that have a notion of successor and predecessor operations.