Implement Bounded for angles
This commit is contained in:
parent
1e98ef4dd4
commit
6981d0cacd
1 changed files with 13 additions and 1 deletions
14
src/angle.rs
14
src/angle.rs
|
@ -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) }
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue