From 694ed7ea1a8fe61b90c103639ef1964ce6173761 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sun, 31 Dec 2023 16:44:57 +0200 Subject: refactor(tvix/store/bin): condense subscriber setup a bit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can use cli.json.then_some(…) to create a Some(…), allowing us to omit the else { None } lines. Change-Id: I6c8142a08d8cb88d6c8302e5ca7570698fcf2aa3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10505 Autosubmit: flokli Reviewed-by: raitobezarius Tested-by: BuildkiteCI --- tvix/store/src/bin/tvix-store.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tvix/store/src/bin/tvix-store.rs b/tvix/store/src/bin/tvix-store.rs index ca79378eb4fc..f241a80bf575 100644 --- a/tvix/store/src/bin/tvix-store.rs +++ b/tvix/store/src/bin/tvix-store.rs @@ -162,24 +162,20 @@ async fn main() -> Result<(), Box> { let level = cli.log_level.unwrap_or(Level::INFO); let subscriber = tracing_subscriber::registry() - .with(if cli.json { - Some( + .with( + cli.json.then_some( tracing_subscriber::fmt::Layer::new() .with_writer(std::io::stderr.with_max_level(level)) .json(), - ) - } else { - None - }) - .with(if !cli.json { - Some( + ), + ) + .with( + (!cli.json).then_some( tracing_subscriber::fmt::Layer::new() .with_writer(std::io::stderr.with_max_level(level)) .pretty(), - ) - } else { - None - }); + ), + ); tracing::subscriber::set_global_default(subscriber).expect("Unable to set global subscriber"); -- cgit 1.4.1