Skip to main content

Module range

Module range 

1.95.0 · Source
Expand description

§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   ]);

Re-exports§

use crate::fmt; 🔒
use crate::hash::Hash; 🔒
use crate::hash::Hash; 🔒
use crate::marker::Destruct; 🔒 Experimental
use core::ops::Bound; 🔒
use core::ops::Bound::Excluded; 🔒
use core::ops::Bound::Included; 🔒
use core::ops::Bound::Unbounded; 🔒
use crate::iter::Step; 🔒 Experimental
use crate::ops::IntoBounds; 🔒 Experimental
use crate::ops::OneSidedRange; 🔒 Experimental
use crate::ops::OneSidedRangeBound; 🔒 Experimental
use crate::ops::RangeBounds; 🔒

Modules§

iter 🔒
legacy
Legacy range types

Structs§

Range
A (half-open) range bounded inclusively below and exclusively above.
RangeFrom
A range only bounded inclusively below.
RangeFromIter
By-value RangeFrom iterator.
RangeFull
An unbounded range (..).
RangeInclusive
A range bounded inclusively below and above.
RangeInclusiveIter
By-value RangeInclusive iterator.
RangeIter
By-value Range iterator.
RangeTo
A range only bounded exclusively above (..end).
RangeToInclusive
A range only bounded inclusively above.

Traits§

RangeIntersectExperimental
Computes the intersection of two ranges, returning the most specific range type possible.