From 16a6ebd75148310121e54434453e48ab9c463cdc Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 23 Apr 2017 03:44:58 +0100 Subject: [PATCH] ibb: Simplify the FromStr using match. --- src/ibb.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/ibb.rs b/src/ibb.rs index a8705cd1..507e3aa4 100644 --- a/src/ibb.rs +++ b/src/ibb.rs @@ -23,13 +23,12 @@ impl FromStr for Stanza { type Err = Error; fn from_str(s: &str) -> Result { - 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.")), + }) } }