data_forms: Simplify the FromStr using match.
This commit is contained in:
parent
90db24eed8
commit
659eaee14e
1 changed files with 8 additions and 11 deletions
|
@ -30,17 +30,14 @@ impl FromStr for DataFormType {
|
|||
type Err = Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<DataFormType, Error> {
|
||||
if s == "cancel" {
|
||||
Ok(DataFormType::Cancel)
|
||||
} else if s == "form" {
|
||||
Ok(DataFormType::Form)
|
||||
} else if s == "result" {
|
||||
Ok(DataFormType::Result_)
|
||||
} else if s == "submit" {
|
||||
Ok(DataFormType::Submit)
|
||||
} else {
|
||||
Err(Error::ParseError("Unknown data form type."))
|
||||
}
|
||||
Ok(match s {
|
||||
"cancel" => DataFormType::Cancel,
|
||||
"form" => DataFormType::Form,
|
||||
"result" => DataFormType::Result_,
|
||||
"submit" => DataFormType::Submit,
|
||||
|
||||
_ => return Err(Error::ParseError("Unknown data form type.")),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue