我正在使用std :: net :: lookup_host.构建时,会发生错误.我正在使用Rust 1.2.
use std::net;
fn main() {
for host in try!(net::lookup_host("rust-lang.org")) {
println!("found address : {}", try!(host));
}
}
Run Code Online (Sandbox Code Playgroud)
错误
<std macros>:5:8: 6:42 error: mismatched types:
expected `()`,
found `core::result::Result<_, _>`
(expected (),
found enum `core::result::Result`) [E0308]
<std macros>:5 return $ crate:: result:: Result:: Err (
<std macros>:6 $ crate:: convert:: From:: from ( err ) ) } } )
<std macros>:1:1: 6:48 note: in expansion of try!
exam.rs:4:14: 4:53 note: expansion site
note: …Run Code Online (Sandbox Code Playgroud) rust ×1