about summary refs log tree commit diff
path: root/tvix/store/src/nixpath.rs
diff options
context:
space:
mode:
authorJürgen Hahn <mail.jhahn@gmail.com>2022-12-30T15·40+0100
committerjrhahn <mail.jhahn@gmail.com>2022-12-30T16·02+0000
commit60bdf619a38f05f8a8815feffc562b0e5c40143f (patch)
treeecf7419331c73bc4e279a2f2b92aafcb99126216 /tvix/store/src/nixpath.rs
parent58f5ff2c173b6c64e3ffb1d2cd4d840e0dcf38c3 (diff)
feat(tvix/store): refactor digest conversion r/5555
This refactors how the original digest type (Vec<u8>) is converted
to [u8; PATH_HASH_SIZE].

Change-Id: I9441470a3a199620fcf328f2b7c890ca6ae93bde
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7710
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to '')
-rw-r--r--tvix/store/src/nixpath.rs6
1 files changed, 1 insertions, 5 deletions
diff --git a/tvix/store/src/nixpath.rs b/tvix/store/src/nixpath.rs
index 8232e3241e..44350803ea 100644
--- a/tvix/store/src/nixpath.rs
+++ b/tvix/store/src/nixpath.rs
@@ -49,13 +49,9 @@ impl NixPath {
 
         NixPath::validate_characters(&s[name_offset..])?;
 
-        // copy the digest:Vec<u8> to a [u8; PATH_HASH_SIZE]
-        let mut buffer: [u8; PATH_HASH_SIZE] = [0; PATH_HASH_SIZE];
-        buffer[..PATH_HASH_SIZE].copy_from_slice(&digest[..PATH_HASH_SIZE]);
-
         Ok(NixPath {
             name: s[name_offset..].to_string(),
-            digest: buffer,
+            digest: digest.try_into().expect("size is known"),
         })
     }