ibb: Simplify the FromStr using match.
This commit is contained in:
parent
659eaee14e
commit
16a6ebd751
1 changed files with 6 additions and 7 deletions
13
src/ibb.rs
13
src/ibb.rs
|
|
@ -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."))
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue