Skip to content

Commit

Permalink
PLCC-287 impl Neg for Measurement
Browse files Browse the repository at this point in the history
  • Loading branch information
turboladen committed Feb 13, 2024
1 parent 422300a commit f4b882a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions crates/api/src/measurement/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@
use crate::{convertible::Convertible, error::Error, measurement::Measurement};
use std::ops::{Add, Div, Mul, Sub};

// ╭──────────╮
// │ impl Neg │
// ╰──────────╯
impl std::ops::Neg for Measurement {
type Output = Self;

fn neg(self) -> Self::Output {
Self {
value: self.value.neg(),
unit: self.unit,
}
}
}

impl<'a> std::ops::Neg for &'a Measurement {
type Output = Measurement;

fn neg(self) -> Self::Output {
Measurement {
value: self.value.neg(),
unit: self.unit.clone(),
}
}
}

//-----------------------------------------------------------------------------
// impl Add
//-----------------------------------------------------------------------------
Expand Down

0 comments on commit f4b882a

Please sign in to comment.