From 60bdf619a38f05f8a8815feffc562b0e5c40143f Mon Sep 17 00:00:00 2001 From: Jürgen Hahn Date: Fri, 30 Dec 2022 16:40:58 +0100 Subject: feat(tvix/store): refactor digest conversion This refactors how the original digest type (Vec) 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 --- tvix/store/src/nixpath.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'tvix/store/src/nixpath.rs') diff --git a/tvix/store/src/nixpath.rs b/tvix/store/src/nixpath.rs index 8232e3241e11..44350803eafa 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 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"), }) } -- cgit 1.4.1