Skip to content

Instantly share code, notes, and snippets.

@claudioap
Last active August 29, 2015 14:20
Show Gist options
  • Save claudioap/6aace07870e4f0b685d3 to your computer and use it in GitHub Desktop.
Save claudioap/6aace07870e4f0b685d3 to your computer and use it in GitHub Desktop.
Something's wrong
use std::net;
fn main() {
// let hostname = &"example.com";
// let lookup = std::net::lookup_host(hostname);
// for address in lookup{
// println!("Found this:{}", address);
// }
for host in try!(net::lookup_host("rust-lang.org")) {
println!("found address: {}", try!(host));
}
}
Compiler's reaction to the official example code:
<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!
src/main.rs:17:17: 17:56 note: expansion site
<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!
src/main.rs:18:43: 18:53 note: expansion site
note: in expansion of format_args!
<std macros>:2:25: 2:56 note: expansion site
<std macros>:1:1: 2:62 note: in expansion of print!
<std macros>:3:1: 3:54 note: expansion site
<std macros>:1:1: 3:58 note: in expansion of println!
src/main.rs:18:13: 18:55 note: expansion site
error: aborting due to 2 previous errors
Could not compile `rust_network`.
An to the commented code:
src/main.rs:14:33: 14:40 error: the trait `core::fmt::Display` is not implemented for the type `std::net::LookupHost` [E0277]
src/main.rs:14 println!("Found this:{}", address);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment