about summary refs log tree commit diff
path: root/tvix/cli/src/derivation.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-01-31T11·28+0100
committerflokli <flokli@flokli.de>2023-01-31T13·26+0000
commit8ea93bb646456864088a2c93e9ab2c4ccae75cba (patch)
tree3befa27f6680b49ddd897c191cec6eaa523deafd /tvix/cli/src/derivation.rs
parent6fa91349a9b97e74cf3dd9833da19b3450045e20 (diff)
refactor(tvix/cli/derivation): use `if let` to destructure r/5787
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 <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/cli/src/derivation.rs')
-rw-r--r--tvix/cli/src/derivation.rs10
1 files changed, 5 insertions, 5 deletions
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<String>, // in nix: outputHashAlgo
     hash_mode: Option<String>, // 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::<ssri::Integrity>();
@@ -176,9 +178,7 @@ fn populate_output_configuration(
 
                 out.hash = Some(Hash { algo, digest });
             }
-        },
-
-        _ => {}
+        }
     }
 
     Ok(())