Skip to content

Instantly share code, notes, and snippets.

@muja
Created July 28, 2015 20:22
impl<F> NetworkConnector for F where F: Fn(&str, u16, &str) -> io::Result<TcpStream> {
type Stream = HttpStream;
fn connect(&self, host: &str, port: u16, scheme: &str) -> ::Result<HttpStream> {
Ok(HttpStream(try!((*self)(host, port, scheme))))
}
}
impl<F> NetworkConnector for F where F: Fn(&str, u16) -> io::Result<TcpStream> {
type Stream = HttpStream;
fn connect(&self, host: &str, port: u16, _scheme: &str) -> ::Result<HttpStream> {
Ok(HttpStream(try!((*self)(host, port))))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment