@@ -979,20 +979,58 @@ impl<T> RangeBounds<T> for RangeToInclusive<&T> {
979979 }
980980}
981981
982+ /// An internal helper for `split_off` functions indicating
983+ /// which end a `OneSidedRange` is bounded on.
984+ #[ unstable( feature = "one_sided_range" , issue = "69780" ) ]
985+ #[ allow( missing_debug_implementations) ]
986+ pub enum OneSidedRangeBound {
987+ /// The range is bounded inclusively from below and is unbounded above.
988+ StartInclusive ,
989+ /// The range is bounded exclusively from above and is unbounded below.
990+ End ,
991+ /// The range is bounded inclusively from above and is unbounded below.
992+ EndInclusive ,
993+ }
994+
982995/// `OneSidedRange` is implemented for built-in range types that are unbounded
983996/// on one side. For example, `a..`, `..b` and `..=c` implement `OneSidedRange`,
984997/// but `..`, `d..e`, and `f..=g` do not.
985998///
986999/// Types that implement `OneSidedRange<T>` must return `Bound::Unbounded`
9871000/// from one of `RangeBounds::start_bound` or `RangeBounds::end_bound`.
9881001#[ unstable( feature = "one_sided_range" , issue = "69780" ) ]
989- pub trait OneSidedRange < T : ?Sized > : RangeBounds < T > { }
1002+ pub trait OneSidedRange < T : ?Sized > : RangeBounds < T > {
1003+ /// An internal-only helper function for `split_off` and
1004+ /// `split_off_mut` that returns the bound of the one-sided range.
1005+ fn bound ( self ) -> ( OneSidedRangeBound , T ) ;
1006+ }
9901007
9911008#[ unstable( feature = "one_sided_range" , issue = "69780" ) ]
992- impl < T > OneSidedRange < T > for RangeTo < T > where Self : RangeBounds < T > { }
1009+ impl < T > OneSidedRange < T > for RangeTo < T >
1010+ where
1011+ Self : RangeBounds < T > ,
1012+ {
1013+ fn bound ( self ) -> ( OneSidedRangeBound , T ) {
1014+ ( OneSidedRangeBound :: End , self . end )
1015+ }
1016+ }
9931017
9941018#[ unstable( feature = "one_sided_range" , issue = "69780" ) ]
995- impl < T > OneSidedRange < T > for RangeFrom < T > where Self : RangeBounds < T > { }
1019+ impl < T > OneSidedRange < T > for RangeFrom < T >
1020+ where
1021+ Self : RangeBounds < T > ,
1022+ {
1023+ fn bound ( self ) -> ( OneSidedRangeBound , T ) {
1024+ ( OneSidedRangeBound :: StartInclusive , self . start )
1025+ }
1026+ }
9961027
9971028#[ unstable( feature = "one_sided_range" , issue = "69780" ) ]
998- impl < T > OneSidedRange < T > for RangeToInclusive < T > where Self : RangeBounds < T > { }
1029+ impl < T > OneSidedRange < T > for RangeToInclusive < T >
1030+ where
1031+ Self : RangeBounds < T > ,
1032+ {
1033+ fn bound ( self ) -> ( OneSidedRangeBound , T ) {
1034+ ( OneSidedRangeBound :: EndInclusive , self . end )
1035+ }
1036+ }
0 commit comments