From ac109bd3faa22669936ff9902860a2c1cafaa17e Mon Sep 17 00:00:00 2001 From: Federico Rinaldi Date: Tue, 17 Dec 2024 15:57:39 +0100 Subject: [PATCH] Use `lyon_path::Build` trait for building paths (#268) --- src/geometry.rs | 23 +++++++---------------- src/lib.rs | 2 +- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/geometry.rs b/src/geometry.rs index 7bed94e..d0502fe 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -1,6 +1,6 @@ //! Types for defining and using geometries. -use lyon_algorithms::path::{builder::WithSvg, BuilderImpl}; +use lyon_algorithms::path::{builder::WithSvg, traits::Build, BuilderImpl}; use lyon_tessellation::path::path::Builder; use crate::{ @@ -144,21 +144,12 @@ impl ShapeBuilderBase for ReadyShapeBuilder Shape; -} - -impl ReadyShapeBuilderTrait for ReadyShapeBuilder { - fn build(self) -> Shape { - Shape::new(self.builder.build(), self.fill, self.stroke) - } -} - -impl ReadyShapeBuilderTrait for ReadyShapeBuilder> { - fn build(self) -> Shape { +impl ReadyShapeBuilder +where + GenericBuilder: Build, +{ + /// Builds the path according to builder settings. + pub fn build(self) -> Shape { Shape::new(self.builder.build(), self.fill, self.stroke) } } diff --git a/src/lib.rs b/src/lib.rs index de8e9bc..76d2786 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,7 +43,7 @@ pub mod prelude { pub use crate::{ draw::{Fill, Stroke}, entity::Shape, - geometry::{Geometry, ReadyShapeBuilderTrait, ShapeBuilder, ShapeBuilderBase}, + geometry::{Geometry, ShapeBuilder, ShapeBuilderBase}, path::ShapePath, plugin::ShapePlugin, shapes::{self, BorderRadii, RectangleOrigin, RegularPolygon, RegularPolygonFeature},