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:
Nicolas Boichat 2025-08-06 15:07:36 +08:00
parent b71d1f8931
commit fa24c8c595

View file

@ -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;
}