From 6981d0cacd58ee596a45eae275072a68cbc2fe7d Mon Sep 17 00:00:00 2001 From: Osspial Date: Tue, 8 Aug 2017 19:17:16 -0400 Subject: [PATCH] Implement Bounded for angles --- src/angle.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/angle.rs b/src/angle.rs index 922ee24..ba5342d 100644 --- a/src/angle.rs +++ b/src/angle.rs @@ -22,7 +22,7 @@ use std::ops::*; use rand::{Rand, Rng}; use rand::distributions::range::SampleRange; -use num_traits::cast; +use num_traits::{cast, Bounded}; use structure::*; @@ -117,6 +117,18 @@ macro_rules! impl_angle { fn neg(self) -> $Angle { $Angle(-self.0) } } + impl Bounded for $Angle { + #[inline] + fn min_value() -> $Angle { + $Angle(S::min_value()) + } + + #[inline] + fn max_value() -> $Angle { + $Angle(S::max_value()) + } + } + impl_operator!( Add<$Angle > for $Angle { fn add(lhs, rhs) -> $Angle { $Angle(lhs.0 + rhs.0) } });