[librsvg: 5/6] text: simplify to not use Option for dx and dy




commit b2490fdd36410d9d325ec6982a15de8efb44fc7a
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Dec 20 12:14:34 2020 +0100

    text: simplify to not use Option for dx and dy
    
    They default to 0, so no need to wrap them in Option<>

 src/text.rs | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/src/text.rs b/src/text.rs
index 4aef2455..c279edd6 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -421,8 +421,8 @@ impl Chars {
 pub struct Text {
     x: Length<Horizontal>,
     y: Length<Vertical>,
-    dx: Option<Length<Horizontal>>,
-    dy: Option<Length<Vertical>>,
+    dx: Length<Horizontal>,
+    dy: Length<Vertical>,
 }
 
 impl Text {
@@ -442,8 +442,8 @@ impl Text {
 
         chunks.push(Chunk::new(&values, Some(x), Some(y)));
 
-        let dx = self.dx.map_or(0.0, |l| l.normalize(&values, &params));
-        let dy = self.dy.map_or(0.0, |l| l.normalize(&values, &params));
+        let dx = self.dx.normalize(&values, &params);
+        let dy = self.dy.normalize(&values, &params);
 
         children_to_chunks(
             &mut chunks,
@@ -596,8 +596,8 @@ impl Draw for TRef {}
 pub struct TSpan {
     x: Option<Length<Horizontal>>,
     y: Option<Length<Vertical>>,
-    dx: Option<Length<Horizontal>>,
-    dy: Option<Length<Vertical>>,
+    dx: Length<Horizontal>,
+    dy: Length<Vertical>,
 }
 
 impl TSpan {
@@ -618,8 +618,8 @@ impl TSpan {
         let x = self.x.map(|l| l.normalize(&values, &params));
         let y = self.y.map(|l| l.normalize(&values, &params));
 
-        let span_dx = dx + self.dx.map_or(0.0, |l| l.normalize(&values, &params));
-        let span_dy = dy + self.dy.map_or(0.0, |l| l.normalize(&values, &params));
+        let span_dx = dx + self.dx.normalize(&values, &params);
+        let span_dy = dy + self.dy.normalize(&values, &params);
 
         if x.is_some() || y.is_some() {
             chunks.push(Chunk::new(values, x, y));


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