From 17aa76ac61baaade0e98805d6bc9132f04a0994a Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 25 Dec 2023 16:15:09 -0800 Subject: [PATCH] Minor cleanup --- src/content/syntax/system.rs | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/src/content/syntax/system.rs b/src/content/syntax/system.rs index 9d7a2fe..6cb3e1d 100644 --- a/src/content/syntax/system.rs +++ b/src/content/syntax/system.rs @@ -63,17 +63,6 @@ pub(in crate::content) mod toml { } } - impl CoordinatesTwo { - /// Transform a CoordinatesThree into a CoordinatesTwo by adding a NaN z component. - /// Labels are not changed. - pub fn to_three(&self) -> CoordinatesThree { - match self { - Self::Label(s) => CoordinatesThree::Label(s.clone()), - Self::Coords(v) => CoordinatesThree::Coords([v[0], v[1], f32::NAN]), - } - } - } - #[derive(Debug, Deserialize)] #[serde(untagged)] pub enum CoordinatesThree { @@ -89,17 +78,6 @@ pub(in crate::content) mod toml { } } } - - impl CoordinatesThree { - /// Transform a CoordinatesThree into a CoordinatesTwo by deleting z component. - /// Labels are not changed. - pub fn to_two(&self) -> CoordinatesTwo { - match self { - Self::Label(s) => CoordinatesTwo::Label(s.clone()), - Self::Coords(v) => CoordinatesTwo::Coords([v[0], v[1]]), - } - } - } } #[derive(Debug)] @@ -158,7 +136,13 @@ fn resolve_position( match &obj.position { toml::Position::Cartesian(c) => Ok(resolve_coordinates(objects, &c, cycle_detector)?), toml::Position::Polar(p) => { - let r = resolve_coordinates(&objects, &p.center.to_three(), cycle_detector)?; + let three = match &p.center { + toml::CoordinatesTwo::Label(s) => toml::CoordinatesThree::Label(s.clone()), + toml::CoordinatesTwo::Coords(v) => { + toml::CoordinatesThree::Coords([v[0], v[1], f32::NAN]) + } + }; + let r = resolve_coordinates(&objects, &three, cycle_detector)?; let plane = Polar { center: (r.x, r.y).into(), radius: p.radius,