chiark / gitweb /
make FaceColourSpecs a type in specs
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 12 Feb 2021 22:57:40 +0000 (22:57 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 13 Feb 2021 01:47:10 +0000 (01:47 +0000)
NFC

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/imports.rs
src/pieces.rs
src/spec.rs

index df0478188250109f9282f7c7944b77e450d02da2..b08cded498369246805e3bfbeb78cf20c7b67cf8 100644 (file)
@@ -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::*;
index 10a1c126f4cdbfc4e9897033ff46fab5047a3544..7c615cb91526a4e1121da05bd72582c9cd09f551 100644 (file)
@@ -153,12 +153,10 @@ impl SimpleShape {
   }
 }
 
-type FacesSpec = IndexVec<FaceId,ColourSpec>;
-
 trait SimplePieceSpec {
   fn outline(&self) -> Result<Box<dyn Outline>, SpecError>;
   fn path(&self) -> Result<Html, SpecError>;
-  fn faces(&self) -> Result<&FacesSpec, SpecError>;
+  fn faces(&self) -> Result<&FaceColourSpecs, SpecError>;
   fn desc(&self) -> Result<Html, SpecError>;
   fn itemname(&self) -> Result<String, SpecError>;
 
@@ -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()
index 73caaeaf6f52dbc635a6aa38827e3d169308b52e..59d55273a75043d6cdf421413b5cc52a7b3d143d 100644 (file)
@@ -192,6 +192,8 @@ pub struct CompassAngle(u8);
 pub mod piece_specs {
   use super::*;
 
+  pub type FaceColourSpecs = IndexVec<FaceId,ColourSpec>;
+
   #[derive(Debug,Serialize,Deserialize)]
   pub struct Disc {
     pub itemname: Option<String>,