summaryrefslogtreecommitdiff
path: root/src/geom/angle.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/geom/angle.rs')
-rw-r--r--src/geom/angle.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/geom/angle.rs b/src/geom/angle.rs
index 8f18210c..cf3e49a0 100644
--- a/src/geom/angle.rs
+++ b/src/geom/angle.rs
@@ -1,8 +1,11 @@
-use super::*;
use decorum::N64;
+use serde::{Deserialize, Serialize};
+
+use super::*;
/// An angle.
#[derive(Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
+#[derive(Serialize, Deserialize)]
pub struct Angle(N64);
impl Angle {
@@ -52,6 +55,13 @@ impl Angle {
}
}
+impl Debug for Angle {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ let unit = AngularUnit::Deg;
+ write!(f, "{}{}", self.to_unit(unit), unit)
+ }
+}
+
impl Display for Angle {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
// Format with the unit that yields the shortest output, preferring
@@ -66,13 +76,6 @@ impl Display for Angle {
}
}
-impl Debug for Angle {
- fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- let unit = AngularUnit::Deg;
- write!(f, "{}{}", self.to_unit(unit), unit)
- }
-}
-
impl Neg for Angle {
type Output = Self;
@@ -134,7 +137,7 @@ impl Sum for Angle {
}
}
/// Different units of angular measurement.
-#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
+#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum AngularUnit {
/// Radians.
Rad,