[librsvg/marker] marker: shorten parse function



commit 5e882862c0e03adbc6c00b709c0659a7ce8b4639
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]