diff options
Diffstat (limited to 'src/geom/spec.rs')
| -rw-r--r-- | src/geom/spec.rs | 27 |
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 { |
