Implement DivAssign for BigUint

This commit is contained in:
Alice Ryhl 2017-08-26 14:35:03 +02:00
parent 17030ea412
commit 04117fafe9
1 changed files with 19 additions and 1 deletions

View File

@ -1,7 +1,7 @@
use std::borrow::Cow; use std::borrow::Cow;
use std::default::Default; use std::default::Default;
use std::iter::repeat; 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::str::{self, FromStr};
use std::fmt; use std::fmt;
use std::cmp; use std::cmp;
@ -635,6 +635,12 @@ impl<'a, 'b> Div<&'b BigUint> for &'a BigUint {
q 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); promote_unsigned_scalars!(impl Div for BigUint, div);
forward_all_scalar_binop_to_val_val!(impl Div<BigDigit> 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 q
} }
} }
impl DivAssign<BigDigit> for BigUint {
#[inline]
fn div_assign(&mut self, other: BigDigit) {
*self = &*self / other;
}
}
impl Div<BigUint> for BigDigit { impl Div<BigUint> for BigDigit {
type Output = BigUint; type Output = BigUint;
@ -672,6 +684,12 @@ impl Div<DoubleBigDigit> for BigUint {
q q
} }
} }
impl DivAssign<DoubleBigDigit> for BigUint {
#[inline]
fn div_assign(&mut self, other: DoubleBigDigit) {
*self = &*self / other;
}
}
impl Div<BigUint> for DoubleBigDigit { impl Div<BigUint> for DoubleBigDigit {
type Output = BigUint; type Output = BigUint;