@@ -807,18 +807,19 @@ pub trait RangeBounds<T: ?Sized> {
807
807
/// assert!(!(0.0..f32::NAN).contains(&0.5));
808
808
/// assert!(!(f32::NAN..1.0).contains(&0.5));
809
809
#[ stable( feature = "range_contains" , since = "1.35.0" ) ]
810
+ #[ default_method_body_is_const]
810
811
fn contains < U > ( & self , item : & U ) -> bool
811
812
where
812
- T : PartialOrd < U > ,
813
- U : ?Sized + PartialOrd < T > ,
813
+ T : ~ const PartialOrd < U > ,
814
+ U : ?Sized + ~ const PartialOrd < T > ,
814
815
{
815
816
( match self . start_bound ( ) {
816
- Included ( start) => start <= item,
817
- Excluded ( start) => start < item,
817
+ Included ( start) => start. le ( item) ,
818
+ Excluded ( start) => start. lt ( item) ,
818
819
Unbounded => true ,
819
820
} ) && ( match self . end_bound ( ) {
820
- Included ( end) => item <= end,
821
- Excluded ( end) => item < end,
821
+ Included ( end) => item. le ( end) ,
822
+ Excluded ( end) => item. lt ( end) ,
822
823
Unbounded => true ,
823
824
} )
824
825
}
@@ -827,7 +828,8 @@ pub trait RangeBounds<T: ?Sized> {
827
828
use self :: Bound :: { Excluded , Included , Unbounded } ;
828
829
829
830
#[ stable( feature = "collections_range" , since = "1.28.0" ) ]
830
- impl < T : ?Sized > RangeBounds < T > for RangeFull {
831
+ #[ rustc_const_unstable( feature = "const_range_bounds" , issue = "none" ) ]
832
+ impl < T : ?Sized > const RangeBounds < T > for RangeFull {
831
833
fn start_bound ( & self ) -> Bound < & T > {
832
834
Unbounded
833
835
}
@@ -837,7 +839,8 @@ impl<T: ?Sized> RangeBounds<T> for RangeFull {
837
839
}
838
840
839
841
#[ stable( feature = "collections_range" , since = "1.28.0" ) ]
840
- impl < T > RangeBounds < T > for RangeFrom < T > {
842
+ #[ rustc_const_unstable( feature = "const_range_bounds" , issue = "none" ) ]
843
+ impl < T > const RangeBounds < T > for RangeFrom < T > {
841
844
fn start_bound ( & self ) -> Bound < & T > {
842
845
Included ( & self . start )
843
846
}
@@ -847,7 +850,8 @@ impl<T> RangeBounds<T> for RangeFrom<T> {
847
850
}
848
851
849
852
#[ stable( feature = "collections_range" , since = "1.28.0" ) ]
850
- impl < T > RangeBounds < T > for RangeTo < T > {
853
+ #[ rustc_const_unstable( feature = "const_range_bounds" , issue = "none" ) ]
854
+ impl < T > const RangeBounds < T > for RangeTo < T > {
851
855
fn start_bound ( & self ) -> Bound < & T > {
852
856
Unbounded
853
857
}
@@ -857,7 +861,8 @@ impl<T> RangeBounds<T> for RangeTo<T> {
857
861
}
858
862
859
863
#[ stable( feature = "collections_range" , since = "1.28.0" ) ]
860
- impl < T > RangeBounds < T > for Range < T > {
864
+ #[ rustc_const_unstable( feature = "const_range_bounds" , issue = "none" ) ]
865
+ impl < T > const RangeBounds < T > for Range < T > {
861
866
fn start_bound ( & self ) -> Bound < & T > {
862
867
Included ( & self . start )
863
868
}
@@ -867,7 +872,8 @@ impl<T> RangeBounds<T> for Range<T> {
867
872
}
868
873
869
874
#[ stable( feature = "collections_range" , since = "1.28.0" ) ]
870
- impl < T > RangeBounds < T > for RangeInclusive < T > {
875
+ #[ rustc_const_unstable( feature = "const_range_bounds" , issue = "none" ) ]
876
+ impl < T > const RangeBounds < T > for RangeInclusive < T > {
871
877
fn start_bound ( & self ) -> Bound < & T > {
872
878
Included ( & self . start )
873
879
}
@@ -883,7 +889,8 @@ impl<T> RangeBounds<T> for RangeInclusive<T> {
883
889
}
884
890
885
891
#[ stable( feature = "collections_range" , since = "1.28.0" ) ]
886
- impl < T > RangeBounds < T > for RangeToInclusive < T > {
892
+ #[ rustc_const_unstable( feature = "const_range_bounds" , issue = "none" ) ]
893
+ impl < T > const RangeBounds < T > for RangeToInclusive < T > {
887
894
fn start_bound ( & self ) -> Bound < & T > {
888
895
Unbounded
889
896
}
@@ -893,7 +900,8 @@ impl<T> RangeBounds<T> for RangeToInclusive<T> {
893
900
}
894
901
895
902
#[ stable( feature = "collections_range" , since = "1.28.0" ) ]
896
- impl < T > RangeBounds < T > for ( Bound < T > , Bound < T > ) {
903
+ #[ rustc_const_unstable( feature = "const_range_bounds" , issue = "none" ) ]
904
+ impl < T > const RangeBounds < T > for ( Bound < T > , Bound < T > ) {
897
905
fn start_bound ( & self ) -> Bound < & T > {
898
906
match * self {
899
907
( Included ( ref start) , _) => Included ( start) ,
@@ -912,7 +920,8 @@ impl<T> RangeBounds<T> for (Bound<T>, Bound<T>) {
912
920
}
913
921
914
922
#[ stable( feature = "collections_range" , since = "1.28.0" ) ]
915
- impl < ' a , T : ?Sized + ' a > RangeBounds < T > for ( Bound < & ' a T > , Bound < & ' a T > ) {
923
+ #[ rustc_const_unstable( feature = "const_range_bounds" , issue = "none" ) ]
924
+ impl < ' a , T : ?Sized + ' a > const RangeBounds < T > for ( Bound < & ' a T > , Bound < & ' a T > ) {
916
925
fn start_bound ( & self ) -> Bound < & T > {
917
926
self . 0
918
927
}
@@ -923,7 +932,8 @@ impl<'a, T: ?Sized + 'a> RangeBounds<T> for (Bound<&'a T>, Bound<&'a T>) {
923
932
}
924
933
925
934
#[ stable( feature = "collections_range" , since = "1.28.0" ) ]
926
- impl < T > RangeBounds < T > for RangeFrom < & T > {
935
+ #[ rustc_const_unstable( feature = "const_range_bounds" , issue = "none" ) ]
936
+ impl < T > const RangeBounds < T > for RangeFrom < & T > {
927
937
fn start_bound ( & self ) -> Bound < & T > {
928
938
Included ( self . start )
929
939
}
@@ -933,7 +943,8 @@ impl<T> RangeBounds<T> for RangeFrom<&T> {
933
943
}
934
944
935
945
#[ stable( feature = "collections_range" , since = "1.28.0" ) ]
936
- impl < T > RangeBounds < T > for RangeTo < & T > {
946
+ #[ rustc_const_unstable( feature = "const_range_bounds" , issue = "none" ) ]
947
+ impl < T > const RangeBounds < T > for RangeTo < & T > {
937
948
fn start_bound ( & self ) -> Bound < & T > {
938
949
Unbounded
939
950
}
@@ -943,7 +954,8 @@ impl<T> RangeBounds<T> for RangeTo<&T> {
943
954
}
944
955
945
956
#[ stable( feature = "collections_range" , since = "1.28.0" ) ]
946
- impl < T > RangeBounds < T > for Range < & T > {
957
+ #[ rustc_const_unstable( feature = "const_range_bounds" , issue = "none" ) ]
958
+ impl < T > const RangeBounds < T > for Range < & T > {
947
959
fn start_bound ( & self ) -> Bound < & T > {
948
960
Included ( self . start )
949
961
}
@@ -953,7 +965,8 @@ impl<T> RangeBounds<T> for Range<&T> {
953
965
}
954
966
955
967
#[ stable( feature = "collections_range" , since = "1.28.0" ) ]
956
- impl < T > RangeBounds < T > for RangeInclusive < & T > {
968
+ #[ rustc_const_unstable( feature = "const_range_bounds" , issue = "none" ) ]
969
+ impl < T > const RangeBounds < T > for RangeInclusive < & T > {
957
970
fn start_bound ( & self ) -> Bound < & T > {
958
971
Included ( self . start )
959
972
}
@@ -963,7 +976,8 @@ impl<T> RangeBounds<T> for RangeInclusive<&T> {
963
976
}
964
977
965
978
#[ stable( feature = "collections_range" , since = "1.28.0" ) ]
966
- impl < T > RangeBounds < T > for RangeToInclusive < & T > {
979
+ #[ rustc_const_unstable( feature = "const_range_bounds" , issue = "none" ) ]
980
+ impl < T > const RangeBounds < T > for RangeToInclusive < & T > {
967
981
fn start_bound ( & self ) -> Bound < & T > {
968
982
Unbounded
969
983
}
0 commit comments