fn to_sockaddrs(
    servers: &[String],
    default_port: u16,
) -> std::result::Result<Vec<SocketAddr>, DigError> {
    Ok(servers
        .iter()
        .map(|addr| {
            // Each address could be invalid, or return multiple SocketAddr.
            match sockaddr_parse_with_port(addr, default_port) {
                Err(e) => Err(DigError::ArgParseError(format!(
                    "failed to parse '{}': {}",
                    addr, e
                ))),
                Ok(addrs) => Ok(addrs),
            }
        })
        .collect::<std::result::Result<Vec<_>, _>>()?
        // We now have a collection of vec::IntoIter<SocketAddr>, flatten.
        // We would use .flat_map(), but it doesn't handle the Error case :(
        .into_iter()
        .flatten()
        .collect())
}
/// Helper function to take a vector of domain/port numbers, and return (a possibly larger) `Vec[SocketAddr]`.
Helper function to take a vector of domain/port numbers, and return (a possibly larger) `Vec[SocketAddr]`.
Helper function to take a vector of domain / port numbers and return ( a possibly larger ) ` Vec [ SocketAddr ] ` .
fn to_sockaddrs(
    servers: &[String],
    default_port: u16,
) -> std::result::Result<Vec<SocketAddr>, DigError> {
    Ok(servers
        .iter()
        .map(|addr| {
            // Each address could be invalid, or return multiple SocketAddr.
            match sockaddr_parse_with_port(addr, default_port) {
                Err(e) => Err(DigError::ArgParseError(format!(
                    "failed to parse '{}': {}",
                    addr, e
                ))),
                Ok(addrs) => Ok(addrs),
            }
        })
        .collect::<std::result::Result<Vec<_>, _>>()?
        // We now have a collection of vec::IntoIter<SocketAddr>, flatten.
        // We would use .flat_map(), but it doesn't handle the Error case :(
        .into_iter()
        .flatten()
        .collect())
}
fn to_sockaddrs ( servers : & [ String ] , default_port : u16 , ) -> std :: result :: Result < Vec < SocketAddr > , DigError > { Ok ( servers . iter ( ) . map ( | addr | { // Each address could be invalid, or return multiple SocketAddr. match sockaddr_parse_with_port ( addr , default_port ) { Err ( e ) => Err ( DigError :: ArgParseError ( format ! ( " " addr e ) ) ) , Ok ( addrs ) => Ok ( addrs ) , } } ) . collect :: < std :: result :: Result < Vec < _ > , _ > > ( ) ? // We now have a collection of vec::IntoIter<SocketAddr>, flatten. // We would use .flat_map(), but it doesn't handle the Error case :( . into_iter ( ) . flatten ( ) . collect ( ) ) }
Helper function to take a vector of domain/port numbers, and return (a possibly larger) `Vec[SocketAddr]`.
Helper function to take a vector of domain / port numbers and return ( a possibly larger ) ` Vec [ SocketAddr ] ` .
servers
&[String]
default_port
u16