data_forms: Simplify the FromStr using match.

This commit is contained in:
Emmanuel Gil Peyrot 2017-04-23 03:42:50 +01:00
commit 659eaee14e

View file

@ -30,17 +30,14 @@ impl FromStr for DataFormType {
type Err = Error; type Err = Error;
fn from_str(s: &str) -> Result<DataFormType, Error> { fn from_str(s: &str) -> Result<DataFormType, Error> {
if s == "cancel" { Ok(match s {
Ok(DataFormType::Cancel) "cancel" => DataFormType::Cancel,
} else if s == "form" { "form" => DataFormType::Form,
Ok(DataFormType::Form) "result" => DataFormType::Result_,
} else if s == "result" { "submit" => DataFormType::Submit,
Ok(DataFormType::Result_)
} else if s == "submit" { _ => return Err(Error::ParseError("Unknown data form type.")),
Ok(DataFormType::Submit) })
} else {
Err(Error::ParseError("Unknown data form type."))
}
} }
} }