From b82237f42223dfeb1f1e8f3acdeefde2b7054059 Mon Sep 17 00:00:00 2001 From: Astro Date: Thu, 2 Aug 2018 20:10:26 +0200 Subject: [PATCH] replace try! with ? syntax --- src/client/auth.rs | 4 ++-- src/client/mod.rs | 2 +- src/component/mod.rs | 2 +- src/happy_eyeballs.rs | 12 ++++-------- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/client/auth.rs b/src/client/auth.rs index 1953dad4..7d933a44 100644 --- a/src/client/auth.rs +++ b/src/client/auth.rs @@ -60,7 +60,7 @@ impl ClientAuth { let name = mech.name().to_owned(); if mech_names.iter().any(|name1| *name1 == name) { println!("SASL mechanism selected: {:?}", name); - let initial = try!(mech.initial()); + let initial = mech.initial()?; let mut this = ClientAuth { state: ClientAuthState::Invalid, mechanism: mech, @@ -111,7 +111,7 @@ impl Future for ClientAuth { match stream.poll() { Ok(Async::Ready(Some(Packet::Stanza(stanza)))) => { if let Ok(challenge) = Challenge::try_from(stanza.clone()) { - let response = try!(self.mechanism.response(&challenge.data)); + let response = self.mechanism.response(&challenge.data)?; self.send(stream, Response { data: response }); self.poll() } else if let Ok(_) = Success::try_from(stanza.clone()) { diff --git a/src/client/mod.rs b/src/client/mod.rs index 95b9242f..4f633eba 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -45,7 +45,7 @@ impl Client { /// Start polling the returned instance so that it will connect /// and yield events. pub fn new(jid: &str, password: &str, handle: Handle) -> Result { - let jid = try!(Jid::from_str(jid)); + let jid = Jid::from_str(jid)?; let password = password.to_owned(); let connect = Self::make_connect(jid.clone(), password.clone(), handle); Ok(Client { diff --git a/src/component/mod.rs b/src/component/mod.rs index 21ef8974..9536f0a8 100644 --- a/src/component/mod.rs +++ b/src/component/mod.rs @@ -42,7 +42,7 @@ impl Component { /// Start polling the returned instance so that it will connect /// and yield events. pub fn new(jid: &str, password: &str, server: &str, port: u16, handle: Handle) -> Result { - let jid = try!(Jid::from_str(jid)); + let jid = Jid::from_str(jid)?; let password = password.to_owned(); let connect = Self::make_connect(jid.clone(), password, server, port, handle); Ok(Component { diff --git a/src/happy_eyeballs.rs b/src/happy_eyeballs.rs index f2cd1a62..2d83301c 100644 --- a/src/happy_eyeballs.rs +++ b/src/happy_eyeballs.rs @@ -18,14 +18,10 @@ pub struct Connecter { impl Connecter { pub fn from_lookup(handle: Handle, domain: &str, srv: &str, fallback_port: u16) -> Result { - let domain = try!( - DNameBuf::from_str(domain) - .map_err(|e| format!("{}", e)) - ); - let srv = try!( - DNameBuf::from_str(srv) - .map_err(|e| format!("{}", e)) - ); + let domain = DNameBuf::from_str(domain) + .map_err(|e| format!("{}", e))?; + let srv = DNameBuf::from_str(srv) + .map_err(|e| format!("{}", e))?; let resolver = Resolver::new(&handle); let lookup = lookup_srv(resolver.clone(), srv, domain, fallback_port);