浏览代码

Implement DivAssign for BigUint

Alice Ryhl 7 年之前
父节点
当前提交
04117fafe9
共有 1 个文件被更改,包括 19 次插入1 次删除
  1. 19 1
      bigint/src/biguint.rs

+ 19 - 1
bigint/src/biguint.rs

@@ -1,7 +1,7 @@
 use std::borrow::Cow;
 use std::default::Default;
 use std::iter::repeat;
-use std::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Rem, Shl, Shr, Sub, AddAssign, SubAssign, MulAssign};
+use std::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Rem, Shl, Shr, Sub, AddAssign, SubAssign, MulAssign, DivAssign};
 use std::str::{self, FromStr};
 use std::fmt;
 use std::cmp;
@@ -635,6 +635,12 @@ impl<'a, 'b> Div<&'b BigUint> for &'a BigUint {
         q
     }
 }
+impl<'a> DivAssign<&'a BigUint> for BigUint {
+    #[inline]
+    fn div_assign(&mut self, other: &'a BigUint) {
+        *self = &*self / other;
+    }
+}
 
 promote_unsigned_scalars!(impl Div for BigUint, div);
 forward_all_scalar_binop_to_val_val!(impl Div<BigDigit> for BigUint, div);
@@ -649,6 +655,12 @@ impl Div<BigDigit> for BigUint {
         q
     }
 }
+impl DivAssign<BigDigit> for BigUint {
+    #[inline]
+    fn div_assign(&mut self, other: BigDigit) {
+        *self = &*self / other;
+    }
+}
 
 impl Div<BigUint> for BigDigit {
     type Output = BigUint;
@@ -672,6 +684,12 @@ impl Div<DoubleBigDigit> for BigUint {
         q
     }
 }
+impl DivAssign<DoubleBigDigit> for BigUint {
+    #[inline]
+    fn div_assign(&mut self, other: DoubleBigDigit) {
+        *self = &*self / other;
+    }
+}
 
 impl Div<BigUint> for DoubleBigDigit {
     type Output = BigUint;