Skip to content

Commit

Permalink
fix rustfmt errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bluejekyll committed Nov 30, 2017
1 parent 7cab261 commit b36d461
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
4 changes: 1 addition & 3 deletions resolver/src/hosts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ pub fn parse_literal_ip(addr: &str) -> Option<RData> {
match IpAddr::from_str(addr) {
Ok(IpAddr::V4(ip4)) => Some(RData::A(ip4)),
Ok(IpAddr::V6(ip6)) => Some(RData::AAAA(ip6)),
Err(_) => {
None
}
Err(_) => None,
}
}

Expand Down
26 changes: 16 additions & 10 deletions resolver/src/resolver_future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use lookup_ip::{InnerLookupIpFuture, LookupIpFuture};
use dns_lru::DnsLru;
use lookup::{self, Lookup};
use lookup::{InnerLookupFuture, LookupEither, LookupFuture};
use hosts::{Hosts, parse_literal_ip};
use hosts::{parse_literal_ip, Hosts};

/// Root Handle to communicate with the ResolverFuture
///
Expand Down Expand Up @@ -245,7 +245,10 @@ impl ResolverFuture {
pub fn lookup_ip(&self, host: &str) -> LookupIpFuture {
// if host is a ip address, return directly.
if let Some(addr) = parse_literal_ip(host) {
return InnerLookupIpFuture::ok(self.client_cache.clone(), Lookup::new(Arc::new(vec![addr])));
return InnerLookupIpFuture::ok(
self.client_cache.clone(),
Lookup::new(Arc::new(vec![addr])),
);
}

let name = match Name::from_str(host) {
Expand Down Expand Up @@ -358,16 +361,19 @@ mod tests {
&io_loop.handle(),
);

let response = io_loop.run(resolver.lookup_ip("10.1.0.2")).expect(
"failed to run lookup",
);

assert_eq!(Some(IpAddr::V4(Ipv4Addr::new(10, 1, 0, 2))), response.iter().next());
let response = io_loop
.run(resolver.lookup_ip("10.1.0.2"))
.expect("failed to run lookup");

let response = io_loop.run(resolver.lookup_ip("2606:2800:220:1:248:1893:25c8:1946")).expect(
"failed to run lookup",
assert_eq!(
Some(IpAddr::V4(Ipv4Addr::new(10, 1, 0, 2))),
response.iter().next()
);

let response = io_loop
.run(resolver.lookup_ip("2606:2800:220:1:248:1893:25c8:1946"))
.expect("failed to run lookup");

assert_eq!(
Some(IpAddr::V6(Ipv6Addr::new(
0x2606,
Expand All @@ -378,7 +384,7 @@ mod tests {
0x1893,
0x25c8,
0x1946,
))),
))),
response.iter().next()
);
}
Expand Down

0 comments on commit b36d461

Please sign in to comment.