summaryrefslogtreecommitdiff
path: root/src/geom/spec.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-06-09 14:05:57 +0200
committerLaurenz <laurmaedje@gmail.com>2021-06-09 22:44:40 +0200
commitbce553a991f19b2b5bb9efef6b74bd12e15a10c6 (patch)
treefa8ed4b3974927b30e6cffd0d71d4c3e980698de /src/geom/spec.rs
parent29cfef0a6dfef5820bda339d327638e285aaf4d3 (diff)
Tidy up
Diffstat (limited to 'src/geom/spec.rs')
-rw-r--r--src/geom/spec.rs27
1 files changed, 8 insertions, 19 deletions
diff --git a/src/geom/spec.rs b/src/geom/spec.rs
index 713f0a16..e7a2d056 100644
--- a/src/geom/spec.rs
+++ b/src/geom/spec.rs
@@ -25,6 +25,14 @@ impl<T> Spec<T> {
vertical: value,
}
}
+
+ /// Convert to the generic representation.
+ pub fn to_gen(self, main: SpecAxis) -> Gen<T> {
+ match main {
+ SpecAxis::Horizontal => Gen::new(self.vertical, self.horizontal),
+ SpecAxis::Vertical => Gen::new(self.horizontal, self.vertical),
+ }
+ }
}
impl Spec<Length> {
@@ -65,17 +73,6 @@ impl<T> Get<SpecAxis> for Spec<T> {
}
}
-impl<T> Switch for Spec<T> {
- type Other = Gen<T>;
-
- fn switch(self, main: SpecAxis) -> Self::Other {
- match main {
- SpecAxis::Horizontal => Gen::new(self.vertical, self.horizontal),
- SpecAxis::Vertical => Gen::new(self.horizontal, self.vertical),
- }
- }
-}
-
impl<T: Debug> Debug for Spec<T> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "Spec({:?}, {:?})", self.horizontal, self.vertical)
@@ -101,14 +98,6 @@ impl SpecAxis {
}
}
-impl Switch for SpecAxis {
- type Other = GenAxis;
-
- fn switch(self, main: SpecAxis) -> Self::Other {
- if self == main { GenAxis::Main } else { GenAxis::Cross }
- }
-}
-
impl Display for SpecAxis {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
f.pad(match self {