[librsvg] paint_server: use associated type instead of generic



commit a6ca08042c49ce07989e7fbaac3593fc8d7a5c58
Author: Paolo Borelli <pborelli gnome org>
Date:   Tue Jan 1 10:02:04 2019 +0100

    paint_server: use associated type instead of generic

 rsvg_internals/src/gradient.rs     |  8 +++++---
 rsvg_internals/src/paint_server.rs | 13 ++++++++++---
 rsvg_internals/src/pattern.rs      |  8 +++++---
 3 files changed, 20 insertions(+), 9 deletions(-)
---
diff --git a/rsvg_internals/src/gradient.rs b/rsvg_internals/src/gradient.rs
index 2b00f518..3e02b89a 100644
--- a/rsvg_internals/src/gradient.rs
+++ b/rsvg_internals/src/gradient.rs
@@ -529,13 +529,15 @@ fn fix_focus_point(fx: f64, fy: f64, cx: f64, cy: f64, radius: f64) -> (f64, f64
     (cx + dx, cy + dy)
 }
 
-impl PaintSource<Gradient> for NodeGradient {
+impl PaintSource for NodeGradient {
+    type Source = Gradient;
+
     fn resolve(
         &self,
         node: &RsvgNode,
         draw_ctx: &mut DrawingCtx,
         bbox: &BoundingBox,
-    ) -> Option<Gradient> {
+    ) -> Option<Self::Source> {
         let gradient =
             node.with_impl(|i: &NodeGradient| i.get_gradient_with_color_stops_from_node(node));
         let mut result = gradient.clone();
@@ -571,7 +573,7 @@ impl PaintSource<Gradient> for NodeGradient {
 
     fn set_pattern_on_draw_context(
         &self,
-        gradient: &Gradient,
+        gradient: &Self::Source,
         values: &ComputedValues,
         draw_ctx: &mut DrawingCtx,
         opacity: &UnitInterval,
diff --git a/rsvg_internals/src/paint_server.rs b/rsvg_internals/src/paint_server.rs
index 366c2b13..ce6750cb 100644
--- a/rsvg_internals/src/paint_server.rs
+++ b/rsvg_internals/src/paint_server.rs
@@ -49,12 +49,19 @@ impl Parse for PaintServer {
     }
 }
 
-pub trait PaintSource<T> {
-    fn resolve(&self, node: &RsvgNode, draw_ctx: &mut DrawingCtx, bbox: &BoundingBox) -> Option<T>;
+pub trait PaintSource {
+    type Source;
+
+    fn resolve(
+        &self,
+        node: &RsvgNode,
+        draw_ctx: &mut DrawingCtx,
+        bbox: &BoundingBox,
+    ) -> Option<Self::Source>;
 
     fn set_pattern_on_draw_context(
         &self,
-        pattern: &T,
+        pattern: &Self::Source,
         values: &ComputedValues,
         draw_ctx: &mut DrawingCtx,
         opacity: &UnitInterval,
diff --git a/rsvg_internals/src/pattern.rs b/rsvg_internals/src/pattern.rs
index 537ce6e5..0badb435 100644
--- a/rsvg_internals/src/pattern.rs
+++ b/rsvg_internals/src/pattern.rs
@@ -233,13 +233,15 @@ impl NodeTrait for NodePattern {
     }
 }
 
-impl PaintSource<Pattern> for NodePattern {
+impl PaintSource for NodePattern {
+    type Source = Pattern;
+
     fn resolve(
         &self,
         node: &RsvgNode,
         draw_ctx: &mut DrawingCtx,
         _bbox: &BoundingBox,
-    ) -> Option<Pattern> {
+    ) -> Option<Self::Source> {
         let node_pattern = node.get_impl::<NodePattern>().unwrap();
         let pattern = &*node_pattern.pattern.borrow();
         let mut result = pattern.clone();
@@ -274,7 +276,7 @@ impl PaintSource<Pattern> for NodePattern {
 
     fn set_pattern_on_draw_context(
         &self,
-        pattern: &Pattern,
+        pattern: &Self::Source,
         values: &ComputedValues,
         draw_ctx: &mut DrawingCtx,
         _opacity: &UnitInterval,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]