From: Ian Jackson Date: Sat, 20 Feb 2021 10:53:34 +0000 (+0000) Subject: Make GenericSimpleShape generic over Outl too X-Git-Tag: otter-0.4.0~411 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=01009bf5e6789564ebcac562397c548792d322cd;p=otter.git Make GenericSimpleShape generic over Outl too NFC Signed-off-by: Ian Jackson --- diff --git a/src/hand.rs b/src/hand.rs index a73c1e4c..77384f8a 100644 --- a/src/hand.rs +++ b/src/hand.rs @@ -16,7 +16,7 @@ struct MagicOwner { #[derive(Debug,Serialize,Deserialize)] struct Hand { - shape: GenericSimpleShape<()>, + shape: GenericSimpleShape<(), OutlineRepr>, } #[derive(Debug,Clone,Default,Serialize,Deserialize)] diff --git a/src/pieces.rs b/src/pieces.rs index 2680fe58..2f11d037 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -12,15 +12,15 @@ type ColourMap = IndexVec; #[derive(Debug,Serialize,Deserialize)] // todo: this serialisation is rather large -pub struct GenericSimpleShape { +pub struct GenericSimpleShape { pub desc: Desc, colours: ColourMap, #[serde(default)] pub edges: ColourMap, #[serde(default="default_edge_width")] pub edge_width: f64, pub itemname: String, - pub outline: OutlineRepr, + pub outline: Outl, } -pub type SimpleShape = GenericSimpleShape; +pub type SimpleShape = GenericSimpleShape; pub const SELECT_SCALE: f64 = 1.1; @@ -111,8 +111,9 @@ pub fn svg_rectangle_path(PosC([x,y]): PosC) -> Html { -x*0.5, -y*0.5, x, y, -x)) } -impl Outline for GenericSimpleShape - where Desc: Debug + Send + Sync + 'static +impl Outline for GenericSimpleShape + where Desc: Debug + Send + Sync + 'static, + Outl: Outline, { delegate! { to self.outline { @@ -147,8 +148,9 @@ impl Piece for SimpleShape { fn itemname(&self) -> &str { self.itemname() } } -impl GenericSimpleShape - where Desc: Debug + Send + Sync + 'static +impl GenericSimpleShape + where Desc: Debug + Send + Sync + 'static, + Outl: Outline, { pub fn count_faces(&self) -> usize { max(self.colours.len(), self.edges.len()) @@ -156,10 +158,10 @@ impl GenericSimpleShape pub fn itemname(&self) -> &str { &self.itemname } #[throws(SpecError)] - pub fn new(desc: Desc, outline: OutlineRepr, + pub fn new(desc: Desc, outline: Outl, def_itemname: &'_ str, common: &SimpleCommon) - -> GenericSimpleShape + -> GenericSimpleShape { let itemname = common.itemname.clone() .unwrap_or_else(|| def_itemname.to_string());