chiark / gitweb /
work around typetag limitation
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 20 Sep 2020 22:45:17 +0000 (23:45 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 20 Sep 2020 22:45:17 +0000 (23:45 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/gamestate.rs
src/pieces.rs
src/shapelib.rs

index 0d231c54fd6755f38cadfab5bd40906fc223016e..56e64c269a2aefdcef0894f6eaca0795dbc900a0 100644 (file)
@@ -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<Html, IE>;
   fn thresh_dragraise(&self, pri : &PieceRenderInstructions)
                       -> Result<Option<Coord>, IE>;
 }
 
+#[typetag::serde]
+pub trait JustOutline : Outline + Send + Debug { }
+
 #[typetag::serde]
 pub trait Piece : Outline + Send + Debug {
   fn resolve_spec_face(&self, face : Option<FaceId>)
index d5df249ac0e596a8717c0d53318e6688fdb0942f..69aacd7b75aabe905ba23cf17ac1079431b87093 100644 (file)
@@ -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 {
index ad007ac7132cc1de06f788c13b9f6225beeb76e1..877b2b82eaf041b809a9a90fcd2303ac946cd7eb 100644 (file)
@@ -124,13 +124,15 @@ struct Item {
   outline: Box<dyn Outline>,
 }
 
-#[typetag::serde(name="Lib")]
 impl Outline for Item { delegate! { to self.outline {
   fn surround_path(&self, pri : &PieceRenderInstructions) -> Result<Html, IE>;
   fn thresh_dragraise(&self, pri : &PieceRenderInstructions)
                       -> Result<Option<Coord>, 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 { }