From f536f77f178f68f0030ceb19b033bed365906d00 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Wed, 28 Feb 2024 17:38:32 -0800 Subject: [PATCH] Fixup to e3b2201f: fix a typo, minor code simplification --- .../poem/local-server-with-browser/src/main.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/examples/poem/local-server-with-browser/src/main.rs b/examples/poem/local-server-with-browser/src/main.rs index 417456a331..77f8a634c1 100644 --- a/examples/poem/local-server-with-browser/src/main.rs +++ b/examples/poem/local-server-with-browser/src/main.rs @@ -19,8 +19,8 @@ async fn main() -> Result<(), std::io::Error> { // To test port assignment, run two instances of this example at once. // - // For ports <1024, running with administrator priveleges would be needed on - // Unix. For port 0, the OS would assign a port and we'd need to find out + // For ports <1024, running with administrator priveledges would be needed + // on Unix. For port 0, the OS would assign a port and we'd need to find out // what that port's number is. let (min_port, max_port) = (8080, 8085); // Using 127.0.0.1 instead of 0.0.0.0 for security; a local server should @@ -32,15 +32,13 @@ async fn main() -> Result<(), std::io::Error> { if port > max_port { return Err(error.unwrap()); } - let listener = TcpListener::bind(format!("{hostname}:{}", port)); + let listener = TcpListener::bind(format!("{hostname}:{port}")); match listener.into_acceptor().await { Ok(a) => break a, - Err(err) => { - // Most likely, another application is bound to this port. - eprintln!("Couldn't bind to port {port}."); - error = Some(err) - } + Err(err) => error = Some(err), }; + // Most likely, another application is bound to this port. + eprintln!("Couldn't bind to port {port}."); port += 1; };