ibb: Simplify the FromStr using match.

This commit is contained in:
Emmanuel Gil Peyrot 2017-04-23 03:44:58 +01:00
commit 16a6ebd751

View file

@ -23,13 +23,12 @@ impl FromStr for Stanza {
type Err = Error; type Err = Error;
fn from_str(s: &str) -> Result<Stanza, Error> { fn from_str(s: &str) -> Result<Stanza, Error> {
if s == "iq" { Ok(match s {
Ok(Stanza::Iq) "iq" => Stanza::Iq,
} else if s == "message" { "message" => Stanza::Message,
Ok(Stanza::Message)
} else { _ => return Err(Error::ParseError("Invalid 'stanza' attribute.")),
Err(Error::ParseError("Invalid 'stanza' attribute.")) })
}
} }
} }