Skip to content

Commit

Permalink
impl Add/Sub/Mul/Div for OrderedFloat
Browse files Browse the repository at this point in the history
Closes #62.
  • Loading branch information
mbrubeck committed Jun 30, 2020
1 parent 57e16fd commit 7084878
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,38 @@ impl<T: Float> DerefMut for OrderedFloat<T> {

impl<T: Float> Eq for OrderedFloat<T> {}

impl<T: Float> Add for OrderedFloat<T> {
type Output = Self;

fn add(self, other: Self) -> Self {
OrderedFloat(self.0 + other.0)
}
}

impl<T: Float> Sub for OrderedFloat<T> {
type Output = Self;

fn sub(self, other: Self) -> Self {
OrderedFloat(self.0 - other.0)
}
}

impl<T: Float> Mul for OrderedFloat<T> {
type Output = Self;

fn mul(self, other: Self) -> Self {
OrderedFloat(self.0 * other.0)
}
}

impl<T: Float> Div for OrderedFloat<T> {
type Output = Self;

fn div(self, other: Self) -> Self {
OrderedFloat(self.0 / other.0)
}
}

impl<T: Float> Bounded for OrderedFloat<T> {
fn min_value() -> Self {
OrderedFloat(T::min_value())
Expand Down

0 comments on commit 7084878

Please sign in to comment.