Split Server::listen into two methods to hack around ICE related to default type params

Trying to default the type parameters leads to an ICE and strange type errors.
I think this is just due to the experimental state of default type params and
this change can be rolled back when they are fixed.
This commit is contained in:
Jonathan Reem
2014-09-10 12:13:18 -07:00
parent 0c674a1376
commit cfd5cf3c68
4 changed files with 20 additions and 13 deletions

View File

@@ -46,11 +46,14 @@ impl Server<HttpListener> {
impl<L: NetworkListener<S, A>, S: NetworkStream, A: NetworkAcceptor<S>> Server<L> {
/// Binds to a socket, and starts handling connections.
pub fn listen<S, A, H, L>(self, handler: H) -> HttpResult<Listening<A>>
where S: NetworkStream,
///
/// This method has unbound type parameters, so can be used when you want to use
/// something other than the provided HttpStream, HttpAcceptor, and HttpListener.
pub fn listen_network<H, S, A, L>(self, handler: H) -> HttpResult<Listening<A>>
where H: Handler<A, S>,
S: NetworkStream,
A: NetworkAcceptor<S>,
H: Handler<A, S>,
L: NetworkListener<S, A> {
L: NetworkListener<S, A>, {
let mut acceptors = Vec::new();
let mut sockets = Vec::new();
for (ip, port) in self.pairs.move_iter() {
@@ -76,6 +79,11 @@ impl<L: NetworkListener<S, A>, S: NetworkStream, A: NetworkAcceptor<S>> Server<L
sockets: sockets,
})
}
/// Binds to a socket and starts handling connections.
pub fn listen<H: Handler<HttpAcceptor, HttpStream>>(self, handler: H) -> HttpResult<Listening<HttpAcceptor>> {
self.listen_network::<H, HttpStream, HttpAcceptor, HttpListener>(handler)
}
}
/// An iterator over incoming connections, represented as pairs of