From a8e5bc45a13b99b966b9cfe746eba91fd07fe873 Mon Sep 17 00:00:00 2001 From: Tim Kuehn Date: Thu, 12 Jan 2017 00:31:46 -0800 Subject: [PATCH] Minor refactor --- src/client.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/client.rs b/src/client.rs index 0187c72..bc1b2ef 100644 --- a/src/client.rs +++ b/src/client.rs @@ -231,11 +231,13 @@ pub mod future { /// Exposes a trait for connecting synchronously to servers. pub mod sync { + use client::future; use futures::Future; use serde::{Deserialize, Serialize}; use std::io; use std::net::ToSocketAddrs; use super::{Client, Options}; + use util::FirstSocketAddr; /// Types that can connect to a server synchronously. pub trait Connect: Sized { @@ -251,14 +253,7 @@ pub mod sync { fn connect(addr: A, options: Options) -> Result where A: ToSocketAddrs { - let addr = if let Some(a) = addr.to_socket_addrs()?.next() { - a - } else { - return Err(io::Error::new(io::ErrorKind::AddrNotAvailable, - "`ToSocketAddrs::to_socket_addrs` returned an empty \ - iterator.")); - }; - ::connect(addr, options).wait() + ::connect(addr.try_first_socket_addr()?, options).wait() } } }