fn main() {
let client = A2SClient::new().unwrap();
let addresses = args().skip(1)
- .flat_map(|arg| arg.to_socket_addrs())
- .flat_map(|iter_addr| iter_addr.flat_map(|sa| match sa {
- SocketAddr::V4(sa4) => Some(sa4),
- _ => None
- })
- );
+ .map(|arg| arg.to_socket_addrs())
+ .map(|lookup_result| match lookup_result {
+ Ok(iter_addr) => {
+ Ok(iter_addr.flat_map(|sa| match sa {
+ SocketAddr::V4(sa4) => Some(sa4),
+ _ => None
+ }))
+ },
+ Err(e) => Err(e)
+ });
for address in addresses {
- println!("Querying address: {}", address);
+ println!("Querying address: {:?}", address);
- let result = HLQueryResult::new(&client, address);
+ let result = HLQueryResult::new(&client, address.unwrap().next().unwrap());
println!("{}\n", serde_json::to_string_pretty(&result).unwrap());
}