feat(net): remove mut requirement for NetworkConnector.connect()

BREAKING CHANGE: Any custom Connectors will need to change to &self in
  the connect method. Any Connectors that needed the mutablity need to
  figure out a synchronization strategy.

  Request::with_connector() takes a &NetworkConnector instead of &mut.
  Any uses of with_connector will need to change to passing &C.
This commit is contained in:
Sean McArthur
2015-05-08 20:54:05 -07:00
parent 7bc4e83ec2
commit 1b318724a5
6 changed files with 16 additions and 16 deletions

View File

@@ -79,7 +79,7 @@ struct MockConnector;
impl net::NetworkConnector for MockConnector {
type Stream = MockStream;
fn connect(&mut self, _: &str, _: u16, _: &str) -> hyper::Result<MockStream> {
fn connect(&self, _: &str, _: u16, _: &str) -> hyper::Result<MockStream> {
Ok(MockStream::new())
}
@@ -93,7 +93,7 @@ fn bench_mock_hyper(b: &mut test::Bencher) {
let url = "http://127.0.0.1:1337/";
b.iter(|| {
let mut req = hyper::client::Request::with_connector(
hyper::Get, hyper::Url::parse(url).unwrap(), &mut MockConnector
hyper::Get, hyper::Url::parse(url).unwrap(), &MockConnector
).unwrap();
req.headers_mut().set(Foo);