@@ -5,7 +5,7 @@ use crate::fmt;
55use crate :: hash:: { Hash , Hasher } ;
66use crate :: intrinsics;
77use crate :: marker:: StructuralPartialEq ;
8- use crate :: ops:: { BitOr , BitOrAssign , Div , Neg , Rem } ;
8+ use crate :: ops:: { BitOr , BitOrAssign , Div , DivAssign , Neg , Rem , RemAssign } ;
99use crate :: str:: FromStr ;
1010
1111use super :: from_str_radix;
@@ -800,6 +800,16 @@ macro_rules! nonzero_integer_signedness_dependent_impls {
800800 }
801801 }
802802
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+
803813 #[ stable( feature = "nonzero_div" , since = "1.51.0" ) ]
804814 impl Rem <$Ty> for $Int {
805815 type Output = $Int;
@@ -812,6 +822,15 @@ macro_rules! nonzero_integer_signedness_dependent_impls {
812822 unsafe { intrinsics:: unchecked_rem( self , other. get( ) ) }
813823 }
814824 }
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+ }
815834 } ;
816835
817836 // Impls for signed nonzero types only.
0 commit comments