From fdc69ef250b44baeec08e32b2084952e2d17fb30 Mon Sep 17 00:00:00 2001 From: Vika Date: Sat, 7 May 2022 20:31:03 +0300 Subject: main.rs: clean up some dumb stuff Match blocks and ifs are actually perfectly usable as expressions. I forgot about that when writing that code. --- src/main.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index b4eeed5..f9815f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,11 +14,10 @@ async fn main() { info!("Starting the kittybox server..."); - let backend_uri: String; - match env::var("BACKEND_URI") { + let backend_uri: String = match env::var("BACKEND_URI") { Ok(val) => { debug!("Backend URI: {}", val); - backend_uri = val + val } Err(_) => { error!("BACKEND_URI is not set, cannot find a database"); @@ -220,13 +219,12 @@ async fn main() { let svc = warp::service(app); - let tcp_listener: std::net::TcpListener; let mut listenfd = listenfd::ListenFd::from_env(); - if let Ok(Some(listener)) = listenfd.take_tcp_listener(0) { - tcp_listener = listener; + let tcp_listener: std::net::TcpListener = if let Ok(Some(listener)) = listenfd.take_tcp_listener(0) { + listener } else { - tcp_listener = std::net::TcpListener::bind(listen_at).unwrap(); - } + std::net::TcpListener::bind(listen_at).unwrap() + }; tcp_listener.set_nonblocking(true).unwrap(); info!("Listening on {}", tcp_listener.local_addr().unwrap()); -- cgit 1.4.1