From d57c0c2879cc1bb6e48dda636eac3dc65d1695d2 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 12 Jul 2017 13:59:30 -0700 Subject: [PATCH] complex: implement add/sub_assign directly --- complex/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/complex/src/lib.rs b/complex/src/lib.rs index b0c2e4c..a47a7e1 100644 --- a/complex/src/lib.rs +++ b/complex/src/lib.rs @@ -527,13 +527,15 @@ mod opassign { impl AddAssign for Complex { fn add_assign(&mut self, other: Complex) { - *self = self.clone() + other; + self.re += other.re; + self.im += other.im; } } impl SubAssign for Complex { fn sub_assign(&mut self, other: Complex) { - *self = self.clone() - other; + self.re -= other.re; + self.im -= other.im; } }