mirror of
https://github.com/uutils/coreutils.git
synced 2025-12-23 08:47:37 +00:00
hostname: *bsd: Collect lookup_host iterator into a vector
dns_lookup 2.1.0 turns the output of lookup_host into an opaque iterator, collect it into a vector instead. And since we're at it, improve error handling instead of just unwrapping the result.
This commit is contained in:
parent
b71d1f8931
commit
fa24c8c595
1 changed files with 3 additions and 1 deletions
|
|
@ -140,7 +140,9 @@ fn display_hostname(matches: &ArgMatches) -> UResult<()> {
|
|||
// use dns-lookup crate instead
|
||||
#[cfg(any(target_os = "freebsd", target_os = "openbsd"))]
|
||||
{
|
||||
let addrs: Vec<std::net::IpAddr> = lookup_host(hostname.as_str()).unwrap();
|
||||
let addrs: Vec<std::net::IpAddr> = lookup_host(hostname.as_str())
|
||||
.map_err_context(|| "failed to lookup hostname".to_owned())?
|
||||
.collect();
|
||||
addresses = addrs;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue