diff options
| author | Peter Jaszkowiak <p.jaszkow@gmail.com> | 2025-02-11 21:58:54 -0700 |
|---|---|---|
| committer | Peter Jaszkowiak <p.jaszkow@gmail.com> | 2025-02-12 17:38:44 -0700 |
| commit | 9c03369c17c6eed8b6471cb7e176f7da99f6cdfb (patch) | |
| tree | e3555ebf2489a264c31c6c0b5a67aa2835908e56 /library/core/src/range.rs | |
| parent | 34a5ea911c56e79bd451c63f04ea2f5023d7d1a3 (diff) | |
| download | rust-9c03369c17c6eed8b6471cb7e176f7da99f6cdfb.tar.gz rust-9c03369c17c6eed8b6471cb7e176f7da99f6cdfb.zip | |
add `IntoBounds` trait
for `range_into_bounds` feature, #136903
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] |
