Skip to content

Commit

Permalink
fix(server): allow Server::local_addr to be called with custom exec…
Browse files Browse the repository at this point in the history
…utor (#2009)

add generic for the executor to server impl block

resolves #1988
  • Loading branch information
Peter Wilkins authored and seanmonstar committed Nov 12, 2019
1 parent 3d676fb commit da16ed6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions examples/single_threaded.rs
Expand Up @@ -37,14 +37,15 @@ fn main() {

let server = Server::bind(&addr)
.executor(exec)
.serve(new_service)
.map_err(|e| eprintln!("server error: {}", e));
.serve(new_service);

println!("Listening on http://{}", addr);

assert_eq!(addr, server.local_addr());

current_thread::Runtime::new()
.expect("rt new")
.spawn(server)
.spawn(server.map_err(|e| eprintln!("server error: {}", e)))
.run()
.expect("rt run");
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/mod.rs
Expand Up @@ -133,7 +133,7 @@ impl Server<AddrIncoming, ()> {
}

#[cfg(feature = "runtime")]
impl<S> Server<AddrIncoming, S> {
impl<S, E> Server<AddrIncoming, S, E> {
/// Returns the local address that this server is bound to.
pub fn local_addr(&self) -> SocketAddr {
self.spawn_all.local_addr()
Expand Down

0 comments on commit da16ed6

Please sign in to comment.