complex: require T:NumAssign for assign ops
This commit is contained in:
parent
686411f44e
commit
055c6693b1
|
@ -521,54 +521,54 @@ impl<T: Clone + Num> Div<Complex<T>> for Complex<T> {
|
|||
mod opassign {
|
||||
use std::ops::{AddAssign, SubAssign, MulAssign, DivAssign};
|
||||
|
||||
use traits::Num;
|
||||
use traits::NumAssign;
|
||||
|
||||
use Complex;
|
||||
|
||||
impl<T: Clone + Num> AddAssign for Complex<T> {
|
||||
impl<T: Clone + NumAssign> AddAssign for Complex<T> {
|
||||
fn add_assign(&mut self, other: Complex<T>) {
|
||||
*self = self.clone() + other;
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clone + Num> SubAssign for Complex<T> {
|
||||
impl<T: Clone + NumAssign> SubAssign for Complex<T> {
|
||||
fn sub_assign(&mut self, other: Complex<T>) {
|
||||
*self = self.clone() - other;
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clone + Num> MulAssign for Complex<T> {
|
||||
impl<T: Clone + NumAssign> MulAssign for Complex<T> {
|
||||
fn mul_assign(&mut self, other: Complex<T>) {
|
||||
*self = self.clone() * other;
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clone + Num> DivAssign for Complex<T> {
|
||||
impl<T: Clone + NumAssign> DivAssign for Complex<T> {
|
||||
fn div_assign(&mut self, other: Complex<T>) {
|
||||
*self = self.clone() / other;
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Num + AddAssign> AddAssign<T> for Complex<T> {
|
||||
impl<T: Clone + NumAssign> AddAssign<T> for Complex<T> {
|
||||
fn add_assign(&mut self, other: T) {
|
||||
self.re += other;
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Num + SubAssign> SubAssign<T> for Complex<T> {
|
||||
impl<T: Clone + NumAssign> SubAssign<T> for Complex<T> {
|
||||
fn sub_assign(&mut self, other: T) {
|
||||
self.re -= other;
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clone + Num + MulAssign> MulAssign<T> for Complex<T> {
|
||||
impl<T: Clone + NumAssign> MulAssign<T> for Complex<T> {
|
||||
fn mul_assign(&mut self, other: T) {
|
||||
self.re *= other.clone();
|
||||
self.im *= other;
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clone + Num + DivAssign> DivAssign<T> for Complex<T> {
|
||||
impl<T: Clone + NumAssign> DivAssign<T> for Complex<T> {
|
||||
fn div_assign(&mut self, other: T) {
|
||||
self.re /= other.clone();
|
||||
self.im /= other;
|
||||
|
@ -577,13 +577,13 @@ mod opassign {
|
|||
|
||||
macro_rules! forward_op_assign {
|
||||
(impl $imp:ident, $method:ident) => {
|
||||
impl<'a, T: Clone + Num> $imp<&'a Complex<T>> for Complex<T> {
|
||||
impl<'a, T: Clone + NumAssign> $imp<&'a Complex<T>> for Complex<T> {
|
||||
#[inline]
|
||||
fn $method(&mut self, other: &Complex<T>) {
|
||||
self.$method(other.clone())
|
||||
}
|
||||
}
|
||||
impl<'a, T: Clone + Num + $imp> $imp<&'a T> for Complex<T> {
|
||||
impl<'a, T: Clone + NumAssign> $imp<&'a T> for Complex<T> {
|
||||
#[inline]
|
||||
fn $method(&mut self, other: &T) {
|
||||
self.$method(other.clone())
|
||||
|
|
Loading…
Reference in New Issue