mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-28 20:16:58 +03:00
028a626a19
stabilize new Range type and iterator For rust-lang/rust#125687 Stabilizes `core::range::Range` and `core::range::RangeIter`, newly stable API: ```rust // in core::range pub struct Range<Idx> { pub start: Idx, pub end: Idx, } impl<Idx: fmt::Debug> fmt::Debug for Range<Idx> { /* ... */ } impl<Idx: PartialOrd<Idx>> Range<Idx> { pub const fn contains<U>(&self, item: &U) -> bool where Idx: [const] PartialOrd<U>, U: ?Sized + [const] PartialOrd<Idx>; pub const fn is_empty(&self) -> bool where Idx: [const] PartialOrd; } impl<Idx: Step> Range<Idx> { pub fn iter(&self) -> RangeIter<Idx>; } impl<T> const RangeBounds<T> for Range<T> { /* ... */ } impl<T> const RangeBounds<T> for Range<&T> { /* ... */ } impl<T> const From<Range<T>> for legacy::Range<T> { /* ... */ } impl<T> const From<legacy::Range<T>> for Range<T> { /* ... */ } pub struct RangeIter<A>(/* ... */); // `RangeIter::remainder` not stabilized impl<A: Step> Iterator for RangeIter<A> { type Item = A; /* ... */ } impl<A: Step> DoubleEndedIterator for RangeIter<A> { /* ... */ } impl<A: Step> FusedIterator for RangeIter<A> { } impl<A: Step> IntoIterator for Range<A> { type Item = A; type IntoIter = RangeIter<A>; /* ... */ } impl ExactSizeIterator for RangeIter<u8> { } impl ExactSizeIterator for RangeIter<i8> { } unsafe impl<T> const SliceIndex<[T]> for range::Range<usize> { type Output = [T]; /* ... */ } unsafe impl const SliceIndex<str> for range::Range<usize> { type Output = str; /* ... */ } ``` Updates docs to reflect stabilization (removed "experimental")