[librsvg] Use ? in favor of map_err



commit 45421b404b52348396d5c07f5e8e3444c5f5577d
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Jan 14 13:38:24 2020 -0600

    Use ? in favor of map_err

 rsvg_internals/src/parsers.rs | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/rsvg_internals/src/parsers.rs b/rsvg_internals/src/parsers.rs
index 5ee31a27..2829d8c9 100644
--- a/rsvg_internals/src/parsers.rs
+++ b/rsvg_internals/src/parsers.rs
@@ -81,13 +81,12 @@ impl<T: Parse> ParseValue<T> for QualName {
 impl Parse for f64 {
     fn parse<'i>(parser: &mut Parser<'i, '_>) -> Result<Self, ParseError<'i>> {
         let loc = parser.current_source_location();
-        parser.expect_number().map_err(|e| e.into()).and_then(|n| {
-            if n.is_finite() {
-                Ok(f64::from(n))
-            } else {
-                Err(loc.new_custom_error(ValueErrorKind::value_error("expected finite number")))
-            }
-        })
+        let n = parser.expect_number()?;
+        if n.is_finite() {
+            Ok(f64::from(n))
+        } else {
+            Err(loc.new_custom_error(ValueErrorKind::value_error("expected finite number")))
+        }
     }
 }
 


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