From 32d1b917fb2e2fa561eb527b62845c5aea13acc2 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 20 Sep 2020 23:45:17 +0100 Subject: [PATCH] work around typetag limitation Signed-off-by: Ian Jackson --- src/gamestate.rs | 4 +++- src/pieces.rs | 1 - src/shapelib.rs | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gamestate.rs b/src/gamestate.rs index 0d231c54..56e64c26 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -80,13 +80,15 @@ type IE = InternalError; type IR = Result<(),IE>; type SE = SVGProcessingError; -#[typetag::serde] pub trait Outline : Send + Debug { fn surround_path(&self, pri : &PieceRenderInstructions) -> Result; fn thresh_dragraise(&self, pri : &PieceRenderInstructions) -> Result, IE>; } +#[typetag::serde] +pub trait JustOutline : Outline + Send + Debug { } + #[typetag::serde] pub trait Piece : Outline + Send + Debug { fn resolve_spec_face(&self, face : Option) diff --git a/src/pieces.rs b/src/pieces.rs index d5df249a..69aacd7b 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -99,7 +99,6 @@ pub fn svg_circle_path(diam: f64) -> Html { path } -#[typetag::serde] impl Outline for SimpleShape { #[throws(IE)] fn surround_path(&self, _pri : &PieceRenderInstructions) -> Html { diff --git a/src/shapelib.rs b/src/shapelib.rs index ad007ac7..877b2b82 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -124,13 +124,15 @@ struct Item { outline: Box, } -#[typetag::serde(name="Lib")] impl Outline for Item { delegate! { to self.outline { fn surround_path(&self, pri : &PieceRenderInstructions) -> Result; fn thresh_dragraise(&self, pri : &PieceRenderInstructions) -> Result, IE>; }}} +#[typetag::serde(name="Lib")] +impl JustOutline for Item { } + #[typetag::serde(name="Lib")] impl Piece for Item { #[throws(SpecError)] @@ -289,7 +291,6 @@ pub fn load(libname: String, dirname: String) { #[derive(Serialize,Deserialize,Debug)] struct Circle { diam: f64 } -#[typetag::serde(name="Circle")] impl Outline for Circle { #[throws(IE)] fn surround_path(&self, _pri : &PieceRenderInstructions) -> Html { @@ -301,6 +302,8 @@ impl Outline for Circle { Some(self.diam / 2) } } +#[typetag::serde(name="Circle")] +impl JustOutline for Circle { } #[derive(Deserialize,Debug)] struct CircleDefn { } -- 2.30.2