diff options
author | Vika <vika@fireburn.ru> | 2022-05-07 20:31:03 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2022-05-07 20:31:03 +0300 |
commit | fdc69ef250b44baeec08e32b2084952e2d17fb30 (patch) | |
tree | 6a296f6281f799f504be5d6ae9cd88da774cf517 /src/main.rs | |
parent | 139b7ec10bc7f08dae9bd57eef8eff73fbb22061 (diff) | |
download | kittybox-fdc69ef250b44baeec08e32b2084952e2d17fb30.tar.zst |
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.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 14 |
1 files changed, 6 insertions, 8 deletions
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()); |