Skip to main content

Module range

Module range 

1.95.0 · Source
Expand description

§Experimental replacement range types

The types within this module are meant to replace the existing Range, 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   ]);

Modules§

legacyExperimental
Legacy range types

Structs§

RangeInclusive
A range bounded inclusively below and above (start..=last).
RangeInclusiveIter
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..).
RangeFromIterExperimental
By-value RangeFrom iterator.
RangeIterExperimental
By-value Range iterator.
RangeToInclusiveExperimental
A range only bounded inclusively above (..=last).