[librsvg] property_bag.rs: Implement parse_or_default() in terms of parse_or_value()



commit 4c4fc481e3751405f20cd608a8cd9052840f15a8
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Sep 4 16:08:17 2017 -0500

    property_bag.rs: Implement parse_or_default() in terms of parse_or_value()

 rust/src/property_bag.rs |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)
---
diff --git a/rust/src/property_bag.rs b/rust/src/property_bag.rs
index 328a493..90b516f 100644
--- a/rust/src/property_bag.rs
+++ b/rust/src/property_bag.rs
@@ -82,15 +82,9 @@ pub fn parse_or_none<T> (pbag: *const RsvgPropertyBag, key: &'static str) -> Res
 }
 
 pub fn parse_or_default<T> (pbag: *const RsvgPropertyBag, key: &'static str) -> Result <T, NodeError>
-    where T: Default + FromStr<Err = AttributeError>
+    where T: Default + FromStr<Err = AttributeError> + Copy
 {
-    let r = parse_or_none::<T> (pbag, key);
-
-    match r {
-        Ok (Some (v)) => Ok (v),
-        Ok (None)     => Ok (T::default ()),
-        Err (e)       => Err (e)
-    }
+    parse_or_value (pbag, key, T::default ())
 }
 
 pub fn parse_or_value<T> (pbag: *const RsvgPropertyBag, key: &'static str, value: T) -> Result <T, NodeError>


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