Implement ShrAssign and ShlAssign for BigUint

This commit is contained in:
Alice Ryhl 2017-09-03 09:56:29 +02:00
parent 2f6c0bf354
commit 555dab7d33
1 changed files with 17 additions and 3 deletions

View File

@ -1,7 +1,9 @@
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, DivAssign, RemAssign, BitAndAssign, BitOrAssign, BitXorAssign};
use std::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Rem, Shl, Shr, Sub,
AddAssign, BitAndAssign, BitOrAssign, BitXorAssign, DivAssign,
MulAssign, RemAssign, ShlAssign, ShrAssign, SubAssign};
use std::str::{self, FromStr};
use std::fmt;
use std::cmp;
@ -346,7 +348,6 @@ impl Shl<usize> for BigUint {
biguint_shl(Cow::Owned(self), rhs)
}
}
impl<'a> Shl<usize> for &'a BigUint {
type Output = BigUint;
@ -356,6 +357,13 @@ impl<'a> Shl<usize> for &'a BigUint {
}
}
impl ShlAssign<usize> for BigUint {
#[inline]
fn shl_assign(&mut self, rhs: usize) {
*self = biguint_shl(Cow::Borrowed(&*self), rhs);
}
}
impl Shr<usize> for BigUint {
type Output = BigUint;
@ -364,7 +372,6 @@ impl Shr<usize> for BigUint {
biguint_shr(Cow::Owned(self), rhs)
}
}
impl<'a> Shr<usize> for &'a BigUint {
type Output = BigUint;
@ -374,6 +381,13 @@ impl<'a> Shr<usize> for &'a BigUint {
}
}
impl ShrAssign<usize> for BigUint {
#[inline]
fn shr_assign(&mut self, rhs: usize) {
*self = biguint_shr(Cow::Borrowed(&*self), rhs);
}
}
impl Zero for BigUint {
#[inline]
fn zero() -> BigUint {