From 8ea93bb646456864088a2c93e9ab2c4ccae75cba Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 31 Jan 2023 12:28:41 +0100 Subject: refactor(tvix/cli/derivation): use `if let` to destructure We only do logic here if algo and hash_mode are Some(_) (and there's an `out` output). The fact we don't do anything in all in other cases is a bit hidden at the bottom. Use if let for the destructuring, and drop the other case. Change-Id: Icc0e38e62947d52d48ef610f754749737977fca9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7966 Reviewed-by: tazjin Tested-by: BuildkiteCI --- tvix/cli/src/derivation.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tvix') diff --git a/tvix/cli/src/derivation.rs b/tvix/cli/src/derivation.rs index b245d9d5d533..2b12f6dd732a 100644 --- a/tvix/cli/src/derivation.rs +++ b/tvix/cli/src/derivation.rs @@ -106,8 +106,10 @@ fn populate_output_configuration( hash_algo: Option, // in nix: outputHashAlgo hash_mode: Option, // in nix: outputHashmode ) -> Result<(), ErrorKind> { - match (hash, hash_algo, hash_mode) { - (Some(digest), Some(algo), hash_mode) => match drv.outputs.get_mut("out") { + // We only do something when `digest` and `algo` are `Some(_)``, and + // there's an `out` output. + if let (Some(digest), Some(algo), hash_mode) = (hash, hash_algo, hash_mode) { + match drv.outputs.get_mut("out") { None => return Err(Error::ConflictingOutputTypes.into()), Some(out) => { let sri_parsed = digest.parse::(); @@ -176,9 +178,7 @@ fn populate_output_configuration( out.hash = Some(Hash { algo, digest }); } - }, - - _ => {} + } } Ok(()) -- cgit 1.4.1