summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Unterwaditzer <markus@unterwaditzer.net>2015-01-22 16:09:01 +0100
committerMarkus Unterwaditzer <markus@unterwaditzer.net>2015-01-22 16:09:01 +0100
commit888a7f6ea6a70d511f93df6ca81c881d0343a224 (patch)
treebdc67065dfc8291b0d710a59d7fe53372a733148
parent3336144e8de4455e10f1fab15f5a60c777386502 (diff)
implement FromStr
-rw-r--r--src/vobject/lib.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/vobject/lib.rs b/src/vobject/lib.rs
index 5c253e2..1f8319e 100644
--- a/src/vobject/lib.rs
+++ b/src/vobject/lib.rs
@@ -6,7 +6,7 @@
use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant};
-
+use std::str::FromStr;
pub struct Property {
@@ -90,6 +90,16 @@ impl Component {
}
}
+impl FromStr for Component {
+ /// Same as `vobject::parse_component`, but without the error messages.
+ fn from_str(s: &str) -> Option<Component> {
+ match parse_component(s) {
+ Ok(x) => Some(x),
+ Err(_) => None
+ }
+ }
+}
+
/// Parse a component. The error value is a human-readable message.
pub fn parse_component(s: &str) -> Result<Component, String> {
// XXX: The unfolding should be worked into the PEG