[librsvg: 7/43] properties: prefer "if let"



commit 20277749224d856c1b84b332e4e3a643a2741fbd
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Oct 13 12:16:30 2019 +0200

    properties: prefer "if let"

 rsvg_internals/src/properties.rs | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)
---
diff --git a/rsvg_internals/src/properties.rs b/rsvg_internals/src/properties.rs
index c6f5561b..e846ff96 100644
--- a/rsvg_internals/src/properties.rs
+++ b/rsvg_internals/src/properties.rs
@@ -427,16 +427,11 @@ impl SpecifiedValues {
             LetterSpacing(ref x)             => self.letter_spacing               = x.clone(),
             LightingColor(ref x)             => self.lighting_color               = x.clone(),
 
-            Marker(ref x) => match *x {
-                SpecifiedValue::Specified(p::Marker(ref v)) => {
-
-                    // Since "marker" is a shorthand property, we'll just expand it here
-                    self.marker_end = SpecifiedValue::Specified(p::MarkerEnd(v.clone()));
-                    self.marker_mid = SpecifiedValue::Specified(p::MarkerMid(v.clone()));
-                    self.marker_start = SpecifiedValue::Specified(p::MarkerStart(v.clone()));
-                },
-
-                _ => (),
+            Marker(ref x) => if let SpecifiedValue::Specified(p::Marker(ref v)) = *x {
+                // Since "marker" is a shorthand property, we'll just expand it here
+                self.marker_end = SpecifiedValue::Specified(p::MarkerEnd(v.clone()));
+                self.marker_mid = SpecifiedValue::Specified(p::MarkerMid(v.clone()));
+                self.marker_start = SpecifiedValue::Specified(p::MarkerStart(v.clone()));
             },
 
             MarkerEnd(ref x)                 => self.marker_end                   = x.clone(),
@@ -612,11 +607,9 @@ impl SpecifiedValues {
         let decl_parser = DeclarationListParser::new(&mut parser, DeclParser);
 
         for decl_result in decl_parser {
-            match decl_result {
-                Ok(declaration) => {
-                    self.set_property_from_declaration(&declaration, important_styles)
-                }
-                Err(_) => (), // invalid property name or invalid value; ignore
+            // ignore invalid property name or value
+            if let Ok(declaration) = decl_result {
+                self.set_property_from_declaration(&declaration, important_styles)
             }
         }
 


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