Skip to content

Commit

Permalink
local_addr should not return an Option
Browse files Browse the repository at this point in the history
  • Loading branch information
dpc authored and ibraheemdev committed Sep 11, 2023
1 parent b38f8ea commit e634196
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,11 @@ impl Server {
}

/// Get the local address of the bound socket
pub fn local_addr(&self) -> Option<io::Result<SocketAddr>> {
let listener = self.listener.as_ref()?;
let addr = listener
pub fn local_addr(&self) -> io::Result<SocketAddr> {
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<T>(&self, http: &mut Http<T>) {
Expand Down

0 comments on commit e634196

Please sign in to comment.