Skip to content

Commit

Permalink
Add Zero impl for OrderedFloat
Browse files Browse the repository at this point in the history
Useful for the pathfinding crate
  • Loading branch information
Uriopass authored Jun 29, 2020
1 parent 90f4ca8 commit 9a241dc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ impl<T: Float> Neg for OrderedFloat<T> {
}
}

impl<T: Float> Zero for OrderedFloat<T> {
fn zero() -> Self { OrderedFloat(T::zero()) }

fn is_zero(&self) -> bool { self.0.is_zero() }
}

/// A wrapper around Floats providing an implementation of Ord and Hash.
///
/// A NaN value cannot be stored in this type.
Expand Down

0 comments on commit 9a241dc

Please sign in to comment.