mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
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;
|
||||
|
||||
fn from_str(s: &str) -> Result<Stanza, Error> {
|
||||
if s == "iq" {
|
||||
Ok(Stanza::Iq)
|
||||
} else if s == "message" {
|
||||
Ok(Stanza::Message)
|
||||
} else {
|
||||
Err(Error::ParseError("Invalid 'stanza' attribute."))
|
||||
}
|
||||
Ok(match s {
|
||||
"iq" => Stanza::Iq,
|
||||
"message" => Stanza::Message,
|
||||
|
||||
_ => return Err(Error::ParseError("Invalid 'stanza' attribute.")),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue