diff --git a/src/server.rs b/src/server.rs index 20164d9..6a17311 100644 --- a/src/server.rs +++ b/src/server.rs @@ -411,12 +411,11 @@ impl Server { } /// Get the local address of the bound socket - pub fn local_addr(&self) -> Option> { - let listener = self.listener.as_ref()?; - let addr = listener + pub fn local_addr(&self) -> io::Result { + self.listener + .as_ref() + .ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Server::bind not called yet"))? .local_addr() - .map_err(|_e| io::Error::new(io::ErrorKind::Other, "Server::bind not called yet")); - Some(addr) } fn configure(&self, http: &mut Http) {