codec_support/codecs: add negation for MV
authorKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 12 Oct 2021 13:41:59 +0000 (15:41 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 14 Oct 2021 14:38:21 +0000 (16:38 +0200)
nihav-codec-support/src/codecs/mod.rs

index 389821eb6c4e1de71642cc44ff18ada1ab4306bc..92dee916db07f818611befffbb83ba400adcf75e 100644 (file)
@@ -1,6 +1,6 @@
 //! Decoder support functions and definitions.
 use std::fmt;
 //! Decoder support functions and definitions.
 use std::fmt;
-use std::ops::{Add, AddAssign, Sub, SubAssign};
+use std::ops::{Add, AddAssign, Sub, SubAssign, Neg};
 
 pub use nihav_core::frame::*;
 use std::mem;
 
 pub use nihav_core::frame::*;
 use std::mem;
@@ -288,6 +288,13 @@ impl SubAssign for MV {
     fn sub_assign(&mut self, other: MV) { self.x -= other.x; self.y -= other.y; }
 }
 
     fn sub_assign(&mut self, other: MV) { self.x -= other.x; self.y -= other.y; }
 }
 
+impl Neg for MV {
+    type Output = MV;
+    fn neg(self) -> Self::Output {
+        MV { x: -self.x, y: -self.y }
+    }
+}
+
 impl fmt::Display for MV {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "{},{}", self.x, self.y)
 impl fmt::Display for MV {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "{},{}", self.x, self.y)