File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -885,7 +885,11 @@ macro_rules! int_impl {
885885 #[ inline]
886886 pub const fn saturating_add_unsigned( self , rhs: $UnsignedT) -> Self {
887887 // Overflow can only happen at the upper bound
888- self . checked_add_unsigned( rhs) . unwrap_or( Self :: MAX )
888+ // We cannot use `unwrap_or` here because it is not `const`
889+ match self . checked_add_unsigned( rhs) {
890+ Some ( x) => x,
891+ None => Self :: MAX ,
892+ }
889893 }
890894
891895 /// Saturating integer subtraction. Computes `self - rhs`, saturating at the
@@ -928,7 +932,11 @@ macro_rules! int_impl {
928932 #[ inline]
929933 pub const fn saturating_sub_unsigned( self , rhs: $UnsignedT) -> Self {
930934 // Overflow can only happen at the lower bound
931- self . checked_sub_unsigned( rhs) . unwrap_or( Self :: MIN )
935+ // We cannot use `unwrap_or` here because it is not `const`
936+ match self . checked_sub_unsigned( rhs) {
937+ Some ( x) => x,
938+ None => Self :: MIN ,
939+ }
932940 }
933941
934942 /// Saturating integer negation. Computes `-self`, returning `MAX` if `self == MIN`
You can’t perform that action at this time.
0 commit comments