chiark / gitweb /
impl OutlineTrait via ambassador for GenericSimpleShape
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 14 May 2022 22:29:21 +0000 (23:29 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 14 May 2022 22:34:39 +0000 (23:34 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/pieces.rs

index bb38f9481fcb10c2652781137b584453c6d8e3e0..0592b0cf2ca8bc6b18cfda1000be8b1c2fcfcf0c 100644 (file)
@@ -105,17 +105,14 @@ pub fn svg_rectangle_path(PosC{coords: [x,y]}: PosC<f64>) -> Html {
            -x*0.5, -y*0.5, x, y, -x)
 }
 
-#[dyn_upcast]
-impl<Desc, Outl:'static> OutlineTrait for GenericSimpleShape<Desc, Outl>
-    where Desc: Debug + Send + Sync + 'static,
-          Outl: OutlineTrait,
-{
-  delegate! {
-    to self.outline {
-      fn outline_path(&self, scale: f64) -> Result<Html,IE>;
-      fn thresh_dragraise(&self) -> Result<Option<Coord>,IE>;
-      fn bbox_approx(&self) -> Result<Rect, IE>;
-    }
+impl_via_ambassador! {
+  #[dyn_upcast]
+  impl [ Desc, Outl:'static ]
+    OutlineTrait for GenericSimpleShape<Desc, Outl>
+  where [ Desc: Debug + Send + Sync + 'static,
+          Outl: OutlineTrait, ]
+  {
+    outline
   }
 }
 //    let edge_attrs = format!(r##"stroke-width="" stroke"##