Implement Bounded for angles

This commit is contained in:
Osspial 2017-08-08 19:17:16 -04:00
parent 1e98ef4dd4
commit 6981d0cacd

View file

@ -22,7 +22,7 @@ use std::ops::*;
use rand::{Rand, Rng}; use rand::{Rand, Rng};
use rand::distributions::range::SampleRange; use rand::distributions::range::SampleRange;
use num_traits::cast; use num_traits::{cast, Bounded};
use structure::*; use structure::*;
@ -117,6 +117,18 @@ macro_rules! impl_angle {
fn neg(self) -> $Angle<S> { $Angle(-self.0) } fn neg(self) -> $Angle<S> { $Angle(-self.0) }
} }
impl<S: Bounded> Bounded for $Angle<S> {
#[inline]
fn min_value() -> $Angle<S> {
$Angle(S::min_value())
}
#[inline]
fn max_value() -> $Angle<S> {
$Angle(S::max_value())
}
}
impl_operator!(<S: BaseFloat> Add<$Angle<S> > for $Angle<S> { impl_operator!(<S: BaseFloat> Add<$Angle<S> > for $Angle<S> {
fn add(lhs, rhs) -> $Angle<S> { $Angle(lhs.0 + rhs.0) } fn add(lhs, rhs) -> $Angle<S> { $Angle(lhs.0 + rhs.0) }
}); });