@@ -874,33 +874,6 @@ bounds instead of overflowing.
874
874
875
875
Basic usage:
876
876
877
- ```
878
- " , $Feature, "assert_eq!(100" , stringify!( $SelfT) , ".saturating_add(1), 101);
879
- assert_eq!(" , stringify!( $SelfT) , "::max_value().saturating_add(100), " , stringify!( $SelfT) ,
880
- "::max_value());" ,
881
- $EndFeature, "
882
- ```" ) ,
883
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
884
- #[ inline]
885
- #[ cfg( stage0) ]
886
- pub fn saturating_add( self , rhs: Self ) -> Self {
887
- match self . checked_add( rhs) {
888
- Some ( x) => x,
889
- None if rhs >= 0 => Self :: max_value( ) ,
890
- None => Self :: min_value( ) ,
891
- }
892
- }
893
-
894
- }
895
-
896
- doc_comment! {
897
- concat!( "Saturating integer addition. Computes `self + rhs`, saturating at the numeric
898
- bounds instead of overflowing.
899
-
900
- # Examples
901
-
902
- Basic usage:
903
-
904
877
```
905
878
" , $Feature, "assert_eq!(100" , stringify!( $SelfT) , ".saturating_add(1), 101);
906
879
assert_eq!(" , stringify!( $SelfT) , "::max_value().saturating_add(100), " , stringify!( $SelfT) ,
@@ -911,37 +884,11 @@ $EndFeature, "
911
884
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
912
885
#[ rustc_const_unstable( feature = "const_saturating_int_methods" ) ]
913
886
#[ inline]
914
- #[ cfg( not( stage0) ) ]
915
887
pub const fn saturating_add( self , rhs: Self ) -> Self {
916
888
intrinsics:: saturating_add( self , rhs)
917
889
}
918
890
}
919
891
920
- doc_comment! {
921
- concat!( "Saturating integer subtraction. Computes `self - rhs`, saturating at the
922
- numeric bounds instead of overflowing.
923
-
924
- # Examples
925
-
926
- Basic usage:
927
-
928
- ```
929
- " , $Feature, "assert_eq!(100" , stringify!( $SelfT) , ".saturating_sub(127), -27);
930
- assert_eq!(" , stringify!( $SelfT) , "::min_value().saturating_sub(100), " , stringify!( $SelfT) ,
931
- "::min_value());" ,
932
- $EndFeature, "
933
- ```" ) ,
934
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
935
- #[ inline]
936
- #[ cfg( stage0) ]
937
- pub fn saturating_sub( self , rhs: Self ) -> Self {
938
- match self . checked_sub( rhs) {
939
- Some ( x) => x,
940
- None if rhs >= 0 => Self :: min_value( ) ,
941
- None => Self :: max_value( ) ,
942
- }
943
- }
944
- }
945
892
946
893
doc_comment! {
947
894
concat!( "Saturating integer subtraction. Computes `self - rhs`, saturating at the
@@ -960,7 +907,6 @@ $EndFeature, "
960
907
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
961
908
#[ rustc_const_unstable( feature = "const_saturating_int_methods" ) ]
962
909
#[ inline]
963
- #[ cfg( not( stage0) ) ]
964
910
pub const fn saturating_sub( self , rhs: Self ) -> Self {
965
911
intrinsics:: saturating_sub( self , rhs)
966
912
}
@@ -2780,29 +2726,6 @@ the numeric bounds instead of overflowing.
2780
2726
2781
2727
Basic usage:
2782
2728
2783
- ```
2784
- " , $Feature, "assert_eq!(100" , stringify!( $SelfT) , ".saturating_add(1), 101);
2785
- assert_eq!(200u8.saturating_add(127), 255);" , $EndFeature, "
2786
- ```" ) ,
2787
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
2788
- #[ inline]
2789
- #[ cfg( stage0) ]
2790
- pub fn saturating_add( self , rhs: Self ) -> Self {
2791
- match self . checked_add( rhs) {
2792
- Some ( x) => x,
2793
- None => Self :: max_value( ) ,
2794
- }
2795
- }
2796
- }
2797
-
2798
- doc_comment! {
2799
- concat!( "Saturating integer addition. Computes `self + rhs`, saturating at
2800
- the numeric bounds instead of overflowing.
2801
-
2802
- # Examples
2803
-
2804
- Basic usage:
2805
-
2806
2729
```
2807
2730
" , $Feature, "assert_eq!(100" , stringify!( $SelfT) , ".saturating_add(1), 101);
2808
2731
assert_eq!(200u8.saturating_add(127), 255);" , $EndFeature, "
@@ -2811,7 +2734,6 @@ assert_eq!(200u8.saturating_add(127), 255);", $EndFeature, "
2811
2734
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2812
2735
#[ rustc_const_unstable( feature = "const_saturating_int_methods" ) ]
2813
2736
#[ inline]
2814
- #[ cfg( not( stage0) ) ]
2815
2737
pub const fn saturating_add( self , rhs: Self ) -> Self {
2816
2738
intrinsics:: saturating_add( self , rhs)
2817
2739
}
@@ -2825,37 +2747,13 @@ at the numeric bounds instead of overflowing.
2825
2747
2826
2748
Basic usage:
2827
2749
2828
- ```
2829
- " , $Feature, "assert_eq!(100" , stringify!( $SelfT) , ".saturating_sub(27), 73);
2830
- assert_eq!(13" , stringify!( $SelfT) , ".saturating_sub(127), 0);" , $EndFeature, "
2831
- ```" ) ,
2832
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
2833
- #[ inline]
2834
- #[ cfg( stage0) ]
2835
- pub fn saturating_sub( self , rhs: Self ) -> Self {
2836
- match self . checked_sub( rhs) {
2837
- Some ( x) => x,
2838
- None => Self :: min_value( ) ,
2839
- }
2840
- }
2841
- }
2842
-
2843
- doc_comment! {
2844
- concat!( "Saturating integer subtraction. Computes `self - rhs`, saturating
2845
- at the numeric bounds instead of overflowing.
2846
-
2847
- # Examples
2848
-
2849
- Basic usage:
2850
-
2851
2750
```
2852
2751
" , $Feature, "assert_eq!(100" , stringify!( $SelfT) , ".saturating_sub(27), 73);
2853
2752
assert_eq!(13" , stringify!( $SelfT) , ".saturating_sub(127), 0);" , $EndFeature, "
2854
2753
```" ) ,
2855
2754
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2856
2755
#[ rustc_const_unstable( feature = "const_saturating_int_methods" ) ]
2857
2756
#[ inline]
2858
- #[ cfg( not( stage0) ) ]
2859
2757
pub const fn saturating_sub( self , rhs: Self ) -> Self {
2860
2758
intrinsics:: saturating_sub( self , rhs)
2861
2759
}
0 commit comments