diff options
Diffstat (limited to 'library/core/src/range.rs')
| -rw-r--r-- | library/core/src/range.rs | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/library/core/src/range.rs b/library/core/src/range.rs index 6a62928873f..e94499065ac 100644 --- a/library/core/src/range.rs +++ b/library/core/src/range.rs @@ -31,7 +31,9 @@ pub use iter::{IterRange, IterRangeFrom, IterRangeInclusive}; #[doc(inline)] pub use crate::iter::Step; #[doc(inline)] -pub use crate::ops::{Bound, OneSidedRange, RangeBounds, RangeFull, RangeTo, RangeToInclusive}; +pub use crate::ops::{ + Bound, IntoBounds, OneSidedRange, RangeBounds, RangeFull, RangeTo, RangeToInclusive, +}; /// A (half-open) range bounded inclusively below and exclusively above /// (`start..end` in a future edition). @@ -175,6 +177,14 @@ impl<T> RangeBounds<T> for Range<&T> { } } +// #[unstable(feature = "range_into_bounds", issue = "136903")] +#[unstable(feature = "new_range_api", issue = "125687")] +impl<T> IntoBounds<T> for Range<T> { + fn into_bounds(self) -> (Bound<T>, Bound<T>) { + (Included(self.start), Excluded(self.end)) + } +} + #[unstable(feature = "new_range_api", issue = "125687")] impl<T> From<Range<T>> for legacy::Range<T> { #[inline] @@ -343,6 +353,14 @@ impl<T> RangeBounds<T> for RangeInclusive<&T> { } } +// #[unstable(feature = "range_into_bounds", issue = "136903")] +#[unstable(feature = "new_range_api", issue = "125687")] +impl<T> IntoBounds<T> for RangeInclusive<T> { + fn into_bounds(self) -> (Bound<T>, Bound<T>) { + (Included(self.start), Included(self.end)) + } +} + #[unstable(feature = "new_range_api", issue = "125687")] impl<T> From<RangeInclusive<T>> for legacy::RangeInclusive<T> { #[inline] @@ -479,6 +497,14 @@ impl<T> RangeBounds<T> for RangeFrom<&T> { } } +// #[unstable(feature = "range_into_bounds", issue = "136903")] +#[unstable(feature = "new_range_api", issue = "125687")] +impl<T> IntoBounds<T> for RangeFrom<T> { + fn into_bounds(self) -> (Bound<T>, Bound<T>) { + (Included(self.start), Unbounded) + } +} + #[unstable(feature = "new_range_api", issue = "125687")] impl<T> From<RangeFrom<T>> for legacy::RangeFrom<T> { #[inline] |
