+pub trait ToAngle {
+ fn radians(self) -> Angle;
+ fn degrees(self) -> Angle;
+}
+
+macro_rules! impl_angle {
+ ($($type:ty),*) => {
+ $(
+ impl ToAngle for $type {
+ fn radians(self) -> Angle {
+ Angle(self as f64)
+ }
+
+ fn degrees(self) -> Angle {
+ Angle((self as f64).to_radians())
+ }
+ }
+
+ impl Mul<$type> for Angle {
+ type Output = Self;
+
+ fn mul(self, rhs: $type) -> Self {
+ Angle(self.0 * (rhs as f64))
+ }
+ }
+
+ impl MulAssign<$type> for Angle {
+ fn mul_assign(&mut self, rhs: $type) {
+ self.0 *= rhs as f64;
+ }
+ }
+
+ impl Div<$type> for Angle {
+ type Output = Self;
+
+ fn div(self, rhs: $type) -> Self {
+ Angle(self.0 / (rhs as f64))
+ }
+ }
+
+ impl DivAssign<$type> for Angle {
+ fn div_assign(&mut self, rhs: $type) {
+ self.0 /= rhs as f64;
+ }
+ }
+ )*