[librsvg: 41/95] property_bag.rs: Remove the parse_or_*() functions. Yay!
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 41/95] property_bag.rs: Remove the parse_or_*() functions. Yay!
- Date: Thu, 22 Feb 2018 03:16:35 +0000 (UTC)
commit 6259ab24f7754555e5cca0e11285dd4dde6a3b0f
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Feb 16 20:10:02 2018 -0600
property_bag.rs: Remove the parse_or_*() functions. Yay!
Now there is just the PropertyBag wrapper in there, and no parsing
stuff.
rust/src/property_bag.rs | 47 -----------------------------------------------
1 file changed, 47 deletions(-)
---
diff --git a/rust/src/property_bag.rs b/rust/src/property_bag.rs
index 53d6a2f0..2c99ed3c 100644
--- a/rust/src/property_bag.rs
+++ b/rust/src/property_bag.rs
@@ -6,9 +6,6 @@ use std::ffi::{CStr, CString};
use std::ops::Deref;
use std::ptr;
-use error::*;
-use parsers::Parse;
-
pub struct PropertyBag<'a>(HashMap<&'a CStr, &'a CStr>);
pub struct OwnedPropertyBag(HashMap<CString, CString>);
@@ -146,50 +143,6 @@ pub extern fn rsvg_property_bag_lookup(pbag: *const PropertyBag,
}
}
-pub fn parse_or_none<T> (pbag: &PropertyBag,
- key: &str,
- data: <T as Parse>::Data,
- validate: Option<fn(T) -> Result<T, AttributeError>>) -> Result <Option<T>,
NodeError>
- where T: Parse<Err = AttributeError> + Copy
-{
- let value = pbag.lookup(key);
-
- match value {
- Some (v) => {
- T::parse (&v, data)
- .and_then (|v|
- if let Some(validate) = validate {
- validate(v)
- .map(Some)
- } else {
- Ok(Some(v))
- })
- .map_err (|e| NodeError::attribute_error (key, e))
- },
-
- None => Ok(None)
- }
-}
-
-pub fn parse_or_default<T> (pbag: &PropertyBag,
- key: &str,
- data: <T as Parse>::Data,
- validate: Option<fn(T) -> Result<T, AttributeError>>) -> Result <T, NodeError>
- where T: Default + Parse<Err = AttributeError> + Copy
-{
- parse_or_value (pbag, key, data, T::default (), validate)
-}
-
-pub fn parse_or_value<T> (pbag: &PropertyBag,
- key: &str,
- data: <T as Parse>::Data,
- value: T,
- validate: Option<fn(T) -> Result<T, AttributeError>>) -> Result <T, NodeError>
- where T: Parse<Err = AttributeError> + Copy
-{
- Ok (parse_or_none (pbag, key, data, validate)?.unwrap_or (value))
-}
-
#[cfg(test)]
mod tests {
use super::*;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]