Skip to content

Instantly share code, notes, and snippets.

@muja
Created July 28, 2015 20:22
Show Gist options
  • Save muja/5a0bb173372cfe71dfa1 to your computer and use it in GitHub Desktop.
Save muja/5a0bb173372cfe71dfa1 to your computer and use it in GitHub Desktop.
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