@@ -701,10 +701,11 @@ assert_eq!((", stringify!($SelfT), "::max_value() - 2).checked_add(3), None);",
701
701
$EndFeature, "
702
702
```" ) ,
703
703
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
704
+ #[ rustc_const_unstable( feature = "const_int_checked" , issue = "53718" ) ]
704
705
#[ must_use = "this returns the result of the operation, \
705
706
without modifying the original"]
706
707
#[ inline]
707
- pub fn checked_add( self , rhs: Self ) -> Option <Self > {
708
+ pub const fn checked_add( self , rhs: Self ) -> Option <Self > {
708
709
let ( a, b) = self . overflowing_add( rhs) ;
709
710
if b { None } else { Some ( a) }
710
711
}
@@ -725,10 +726,11 @@ assert_eq!((", stringify!($SelfT), "::min_value() + 2).checked_sub(3), None);",
725
726
$EndFeature, "
726
727
```" ) ,
727
728
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
729
+ #[ rustc_const_unstable( feature = "const_int_checked" , issue = "53718" ) ]
728
730
#[ must_use = "this returns the result of the operation, \
729
731
without modifying the original"]
730
732
#[ inline]
731
- pub fn checked_sub( self , rhs: Self ) -> Option <Self > {
733
+ pub const fn checked_sub( self , rhs: Self ) -> Option <Self > {
732
734
let ( a, b) = self . overflowing_sub( rhs) ;
733
735
if b { None } else { Some ( a) }
734
736
}
@@ -749,10 +751,11 @@ assert_eq!(", stringify!($SelfT), "::max_value().checked_mul(2), None);",
749
751
$EndFeature, "
750
752
```" ) ,
751
753
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
754
+ #[ rustc_const_unstable( feature = "const_int_checked" , issue = "53718" ) ]
752
755
#[ must_use = "this returns the result of the operation, \
753
756
without modifying the original"]
754
757
#[ inline]
755
- pub fn checked_mul( self , rhs: Self ) -> Option <Self > {
758
+ pub const fn checked_mul( self , rhs: Self ) -> Option <Self > {
756
759
let ( a, b) = self . overflowing_mul( rhs) ;
757
760
if b { None } else { Some ( a) }
758
761
}
@@ -889,8 +892,9 @@ assert_eq!(", stringify!($SelfT), "::MIN.checked_neg(), None);",
889
892
$EndFeature, "
890
893
```" ) ,
891
894
#[ stable( feature = "wrapping" , since = "1.7.0" ) ]
895
+ #[ rustc_const_unstable( feature = "const_int_checked" , issue = "53718" ) ]
892
896
#[ inline]
893
- pub fn checked_neg( self ) -> Option <Self > {
897
+ pub const fn checked_neg( self ) -> Option <Self > {
894
898
let ( a, b) = self . overflowing_neg( ) ;
895
899
if b { None } else { Some ( a) }
896
900
}
@@ -910,10 +914,11 @@ assert_eq!(0x1", stringify!($SelfT), ".checked_shl(129), None);",
910
914
$EndFeature, "
911
915
```" ) ,
912
916
#[ stable( feature = "wrapping" , since = "1.7.0" ) ]
917
+ #[ rustc_const_unstable( feature = "const_int_checked" , issue = "53718" ) ]
913
918
#[ must_use = "this returns the result of the operation, \
914
919
without modifying the original"]
915
920
#[ inline]
916
- pub fn checked_shl( self , rhs: u32 ) -> Option <Self > {
921
+ pub const fn checked_shl( self , rhs: u32 ) -> Option <Self > {
917
922
let ( a, b) = self . overflowing_shl( rhs) ;
918
923
if b { None } else { Some ( a) }
919
924
}
@@ -933,10 +938,11 @@ assert_eq!(0x10", stringify!($SelfT), ".checked_shr(128), None);",
933
938
$EndFeature, "
934
939
```" ) ,
935
940
#[ stable( feature = "wrapping" , since = "1.7.0" ) ]
941
+ #[ rustc_const_unstable( feature = "const_int_checked" , issue = "53718" ) ]
936
942
#[ must_use = "this returns the result of the operation, \
937
943
without modifying the original"]
938
944
#[ inline]
939
- pub fn checked_shr( self , rhs: u32 ) -> Option <Self > {
945
+ pub const fn checked_shr( self , rhs: u32 ) -> Option <Self > {
940
946
let ( a, b) = self . overflowing_shr( rhs) ;
941
947
if b { None } else { Some ( a) }
942
948
}
@@ -958,8 +964,9 @@ assert_eq!(", stringify!($SelfT), "::MIN.checked_abs(), None);",
958
964
$EndFeature, "
959
965
```" ) ,
960
966
#[ stable( feature = "no_panic_abs" , since = "1.13.0" ) ]
967
+ #[ rustc_const_unstable( feature = "const_int_checked" , issue = "53718" ) ]
961
968
#[ inline]
962
- pub fn checked_abs( self ) -> Option <Self > {
969
+ pub const fn checked_abs( self ) -> Option <Self > {
963
970
if self . is_negative( ) {
964
971
self . checked_neg( )
965
972
} else {
@@ -2855,10 +2862,11 @@ Basic usage:
2855
2862
assert_eq!((" , stringify!( $SelfT) , "::max_value() - 2).checked_add(3), None);" , $EndFeature, "
2856
2863
```" ) ,
2857
2864
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2865
+ #[ rustc_const_unstable( feature = "const_int_checked" , issue = "53718" ) ]
2858
2866
#[ must_use = "this returns the result of the operation, \
2859
2867
without modifying the original"]
2860
2868
#[ inline]
2861
- pub fn checked_add( self , rhs: Self ) -> Option <Self > {
2869
+ pub const fn checked_add( self , rhs: Self ) -> Option <Self > {
2862
2870
let ( a, b) = self . overflowing_add( rhs) ;
2863
2871
if b { None } else { Some ( a) }
2864
2872
}
@@ -2877,10 +2885,11 @@ Basic usage:
2877
2885
assert_eq!(0" , stringify!( $SelfT) , ".checked_sub(1), None);" , $EndFeature, "
2878
2886
```" ) ,
2879
2887
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2888
+ #[ rustc_const_unstable( feature = "const_int_checked" , issue = "53718" ) ]
2880
2889
#[ must_use = "this returns the result of the operation, \
2881
2890
without modifying the original"]
2882
2891
#[ inline]
2883
- pub fn checked_sub( self , rhs: Self ) -> Option <Self > {
2892
+ pub const fn checked_sub( self , rhs: Self ) -> Option <Self > {
2884
2893
let ( a, b) = self . overflowing_sub( rhs) ;
2885
2894
if b { None } else { Some ( a) }
2886
2895
}
@@ -2899,10 +2908,11 @@ Basic usage:
2899
2908
assert_eq!(" , stringify!( $SelfT) , "::max_value().checked_mul(2), None);" , $EndFeature, "
2900
2909
```" ) ,
2901
2910
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2911
+ #[ rustc_const_unstable( feature = "const_int_checked" , issue = "53718" ) ]
2902
2912
#[ must_use = "this returns the result of the operation, \
2903
2913
without modifying the original"]
2904
2914
#[ inline]
2905
- pub fn checked_mul( self , rhs: Self ) -> Option <Self > {
2915
+ pub const fn checked_mul( self , rhs: Self ) -> Option <Self > {
2906
2916
let ( a, b) = self . overflowing_mul( rhs) ;
2907
2917
if b { None } else { Some ( a) }
2908
2918
}
@@ -3029,8 +3039,9 @@ Basic usage:
3029
3039
assert_eq!(1" , stringify!( $SelfT) , ".checked_neg(), None);" , $EndFeature, "
3030
3040
```" ) ,
3031
3041
#[ stable( feature = "wrapping" , since = "1.7.0" ) ]
3042
+ #[ rustc_const_unstable( feature = "const_int_checked" , issue = "53718" ) ]
3032
3043
#[ inline]
3033
- pub fn checked_neg( self ) -> Option <Self > {
3044
+ pub const fn checked_neg( self ) -> Option <Self > {
3034
3045
let ( a, b) = self . overflowing_neg( ) ;
3035
3046
if b { None } else { Some ( a) }
3036
3047
}
@@ -3049,10 +3060,11 @@ Basic usage:
3049
3060
assert_eq!(0x10" , stringify!( $SelfT) , ".checked_shl(129), None);" , $EndFeature, "
3050
3061
```" ) ,
3051
3062
#[ stable( feature = "wrapping" , since = "1.7.0" ) ]
3063
+ #[ rustc_const_unstable( feature = "const_int_checked" , issue = "53718" ) ]
3052
3064
#[ must_use = "this returns the result of the operation, \
3053
3065
without modifying the original"]
3054
3066
#[ inline]
3055
- pub fn checked_shl( self , rhs: u32 ) -> Option <Self > {
3067
+ pub const fn checked_shl( self , rhs: u32 ) -> Option <Self > {
3056
3068
let ( a, b) = self . overflowing_shl( rhs) ;
3057
3069
if b { None } else { Some ( a) }
3058
3070
}
@@ -3071,10 +3083,11 @@ Basic usage:
3071
3083
assert_eq!(0x10" , stringify!( $SelfT) , ".checked_shr(129), None);" , $EndFeature, "
3072
3084
```" ) ,
3073
3085
#[ stable( feature = "wrapping" , since = "1.7.0" ) ]
3086
+ #[ rustc_const_unstable( feature = "const_int_checked" , issue = "53718" ) ]
3074
3087
#[ must_use = "this returns the result of the operation, \
3075
3088
without modifying the original"]
3076
3089
#[ inline]
3077
- pub fn checked_shr( self , rhs: u32 ) -> Option <Self > {
3090
+ pub const fn checked_shr( self , rhs: u32 ) -> Option <Self > {
3078
3091
let ( a, b) = self . overflowing_shr( rhs) ;
3079
3092
if b { None } else { Some ( a) }
3080
3093
}
0 commit comments