@@ -5,7 +5,7 @@ use crate::fmt;
5
5
use crate :: hash:: { Hash , Hasher } ;
6
6
use crate :: intrinsics;
7
7
use crate :: marker:: StructuralPartialEq ;
8
- use crate :: ops:: { BitOr , BitOrAssign , Div , Neg , Rem } ;
8
+ use crate :: ops:: { BitOr , BitOrAssign , Div , DivAssign , Neg , Rem , RemAssign } ;
9
9
use crate :: str:: FromStr ;
10
10
11
11
use super :: from_str_radix;
@@ -800,6 +800,16 @@ macro_rules! nonzero_integer_signedness_dependent_impls {
800
800
}
801
801
}
802
802
803
+ #[ stable( feature = "nonzero_div_assign" , since = "CURRENT_RUSTC_VERSION" ) ]
804
+ impl DivAssign <$Ty> for $Int {
805
+ /// This operation rounds towards zero,
806
+ /// truncating any fractional part of the exact result, and cannot panic.
807
+ #[ inline]
808
+ fn div_assign( & mut self , other: $Ty) {
809
+ * self = * self / other;
810
+ }
811
+ }
812
+
803
813
#[ stable( feature = "nonzero_div" , since = "1.51.0" ) ]
804
814
impl Rem <$Ty> for $Int {
805
815
type Output = $Int;
@@ -812,6 +822,15 @@ macro_rules! nonzero_integer_signedness_dependent_impls {
812
822
unsafe { intrinsics:: unchecked_rem( self , other. get( ) ) }
813
823
}
814
824
}
825
+
826
+ #[ stable( feature = "nonzero_div_assign" , since = "CURRENT_RUSTC_VERSION" ) ]
827
+ impl RemAssign <$Ty> for $Int {
828
+ /// This operation satisfies `n % d == n - (n / d) * d`, and cannot panic.
829
+ #[ inline]
830
+ fn rem_assign( & mut self , other: $Ty) {
831
+ * self = * self % other;
832
+ }
833
+ }
815
834
} ;
816
835
817
836
// Impls for signed nonzero types only.
0 commit comments