[librsvg/marker: 9/9] marker: shorten parse function



commit 893e7ae8b88bad823662d3f5b80b002136fdfaf0
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Jan 4 12:59:13 2020 +0100

    marker: shorten parse function

 rsvg_internals/src/marker.rs | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
---
diff --git a/rsvg_internals/src/marker.rs b/rsvg_internals/src/marker.rs
index a306f176..346dfb07 100644
--- a/rsvg_internals/src/marker.rs
+++ b/rsvg_internals/src/marker.rs
@@ -61,14 +61,9 @@ impl Default for MarkerOrient {
 
 impl Parse for MarkerOrient {
     fn parse<'i>(parser: &mut Parser<'i, '_>) -> Result<MarkerOrient, CssParseError<'i>> {
-        if parser
-            .try_parse(|p| p.expect_ident_matching("auto"))
-            .is_ok()
-        {
-            Ok(MarkerOrient::Auto)
-        } else {
-            Angle::parse(parser).map(MarkerOrient::Angle)
-        }
+        parser
+            .try_parse(|p| p.expect_ident_matching("auto").map(|_| MarkerOrient::Auto))
+            .or_else(|_| Angle::parse(parser).map(MarkerOrient::Angle))
     }
 }
 


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