Module range

Replacement range types

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

use core::range::{Range, RangeFrom, RangeInclusive, RangeToInclusive};

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[RangeToInclusive::from( ..=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

Structs