From 51ca7dc45e138e2090f7d224535627d00e3fafd4 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 12 Feb 2021 22:57:40 +0000 Subject: [PATCH] make FaceColourSpecs a type in specs NFC Signed-off-by: Ian Jackson --- src/imports.rs | 1 + src/pieces.rs | 8 +++----- src/spec.rs | 2 ++ 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/imports.rs b/src/imports.rs index df047818..b08cded4 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -101,6 +101,7 @@ pub use crate::pieces::*; pub use crate::shapelib; pub use crate::slotmap_slot_idx::*; pub use crate::spec::*; +pub use crate::spec::piece_specs::FaceColourSpecs; pub use crate::sse; pub use crate::toml_de; pub use crate::tz::*; diff --git a/src/pieces.rs b/src/pieces.rs index 10a1c126..7c615cb9 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -153,12 +153,10 @@ impl SimpleShape { } } -type FacesSpec = IndexVec; - trait SimplePieceSpec { fn outline(&self) -> Result, SpecError>; fn path(&self) -> Result; - fn faces(&self) -> Result<&FacesSpec, SpecError>; + fn faces(&self) -> Result<&FaceColourSpecs, SpecError>; fn desc(&self) -> Result; fn itemname(&self) -> Result; @@ -179,7 +177,7 @@ impl SimplePieceSpec for piece_specs::Disc { #[throws(SpecError)] fn path(&self) -> Html { svg_circle_path(self.diam as f64)? } - #[throws(SpecError)] fn faces(&self) -> &FacesSpec { &self.faces } + #[throws(SpecError)] fn faces(&self) -> &FaceColourSpecs { &self.faces } #[throws(SpecError)] fn desc(&self) -> Html { Html::lit("disc") } #[throws(SpecError)] fn itemname(&self) -> String { self.itemname.clone() @@ -211,7 +209,7 @@ impl SimplePieceSpec for piece_specs::Square { #[throws(SpecError)] fn path(&self) -> Html { svg_rectangle_path(self.xy()?.promote())? } - #[throws(SpecError)] fn faces(&self) -> &FacesSpec { &self.faces } + #[throws(SpecError)] fn faces(&self) -> &FaceColourSpecs { &self.faces } #[throws(SpecError)] fn desc(&self) -> Html { Html::lit("square") } #[throws(SpecError)] fn itemname(&self) -> String { self.itemname.clone() diff --git a/src/spec.rs b/src/spec.rs index 73caaeaf..59d55273 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -192,6 +192,8 @@ pub struct CompassAngle(u8); pub mod piece_specs { use super::*; + pub type FaceColourSpecs = IndexVec; + #[derive(Debug,Serialize,Deserialize)] pub struct Disc { pub itemname: Option, -- 2.30.2