diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2019-11-10 00:57:59 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2019-12-21 15:49:42 +0100 |
commit | 2f691190781800e011df51f2cada6a11bbb2c3a0 (patch) | |
tree | 2ab1a05f83ce2298d6a38a03f5ef55f40d9cd158 | |
parent | 83d4aaf55c0b7f995055a7cb4379d1f3451269e9 (diff) |
Impl FromStr instead of own function
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | bin/domain/imag-todo/src/lib.rs | 1 | ||||
-rw-r--r-- | lib/domain/libimagtodo/src/status.rs | 8 |
2 files changed, 8 insertions, 1 deletions
diff --git a/bin/domain/imag-todo/src/lib.rs b/bin/domain/imag-todo/src/lib.rs index ff6ba777..968b4d14 100644 --- a/bin/domain/imag-todo/src/lib.rs +++ b/bin/domain/imag-todo/src/lib.rs @@ -70,6 +70,7 @@ extern crate libimaginteraction; use std::ops::Deref; use std::io::Write; use std::result::Result as RResult; +use std::str::FromStr; use clap::ArgMatches; use chrono::NaiveDateTime; diff --git a/lib/domain/libimagtodo/src/status.rs b/lib/domain/libimagtodo/src/status.rs index 63d8fa03..0edc2492 100644 --- a/lib/domain/libimagtodo/src/status.rs +++ b/lib/domain/libimagtodo/src/status.rs @@ -17,6 +17,8 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // +use std::str::FromStr; + use failure::Fallible as Result; #[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)] @@ -39,8 +41,12 @@ impl Status { Status::Deleted => "deleted", } } +} + +impl FromStr for Status { + type Err = failure::Error; - pub fn from_str(s: &str) -> Result<Self> { + fn from_str(s: &str) -> Result<Self> { match s { "pending" => Ok(Status::Pending), "done" => Ok(Status::Done), |