fn main() {
let port = 3000;
let host = format!("127.0.0.1:{}", port);
Server::http(hello).listen(&host).unwrap();
println!("Listening port {} on 127.0.0.1", port);
}
What I get is the error from the compiler about incompatible types:
src/main.rs:19:25: 19:38 error: the trait `std::net::addr::ToSocketAddrs` is not implemented for the type `collections::string::String` [E0277]
src/main.rs:19 Server::http(hello).listen(&host).unwrap();
^~~~~~~~~~~~~
error: aborting due to previous error
Could not compile `id`.
I had exactly the same confusion using the postgres library the other day. Once I figured out I needed to be explicit I wound up using .borrow(). I'd go so far as to suggest the book needs a sentence of warning where it says "Strings will coerce into &str with an &" to point out that coercion is not the same as a cast. Is it just me (and @can3p)?
This has hung me up several times recently (though I'm not processing Unicode, so it usually bytes me in the Vec<u8> / &[u8] relation). I was pretty sure that this feature had been removed since the book was updated. Thanks for the clarification and the RFC pointer.
Definitely think this deserves at least a footnote in the book. I also read through the language reference but don't see any mention of this.