From: Ian Jackson Date: Sun, 20 Sep 2020 22:45:17 +0000 (+0100) Subject: work around typetag limitation X-Git-Tag: otter-0.2.0~920 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=32d1b917fb2e2fa561eb527b62845c5aea13acc2;p=otter.git work around typetag limitation Signed-off-by: Ian Jackson --- 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 { }