diff options
author | Florian Klink <flokli@flokli.de> | 2024-10-13T15·31+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-10-17T21·17+0000 |
commit | cdbdd2d04ecb2675f9c1d7ded7d99ad3a483b6fc (patch) | |
tree | 83c68d68e44e3b056213c58e4c9f03e18a1fb860 /tvix/castore/src/import/archive.rs | |
parent | a94414e7ffc5c21874fa0ea6e92aa63fcc55cb7d (diff) |
refactor(tvix/castore): remove use of lazy_static r/8823
This is now supported in the standard library via std::sync::LazyLock, but requires some manual shuffling around of code. Change-Id: Ia0370ca46cb1c6122a452b1d117160536b632c7e Reviewed-on: https://cl.tvl.fyi/c/depot/+/12612 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/castore/src/import/archive.rs')
-rw-r--r-- | tvix/castore/src/import/archive.rs | 65 |
1 files changed, 32 insertions, 33 deletions
diff --git a/tvix/castore/src/import/archive.rs b/tvix/castore/src/import/archive.rs index 167f799efa0f..4cbff687b864 100644 --- a/tvix/castore/src/import/archive.rs +++ b/tvix/castore/src/import/archive.rs @@ -292,44 +292,43 @@ impl IngestionEntryGraph { #[cfg(test)] mod test { - use crate::import::IngestionEntry; - use crate::B3Digest; + use std::sync::LazyLock; use super::{Error, IngestionEntryGraph}; + use crate::import::IngestionEntry; + use crate::B3Digest; - use lazy_static::lazy_static; use rstest::rstest; - lazy_static! { - pub static ref EMPTY_DIGEST: B3Digest = blake3::hash(&[]).as_bytes().into(); - pub static ref DIR_A: IngestionEntry = IngestionEntry::Dir { - path: "a".parse().unwrap() - }; - pub static ref DIR_B: IngestionEntry = IngestionEntry::Dir { - path: "b".parse().unwrap() - }; - pub static ref DIR_A_B: IngestionEntry = IngestionEntry::Dir { - path: "a/b".parse().unwrap() - }; - pub static ref FILE_A: IngestionEntry = IngestionEntry::Regular { - path: "a".parse().unwrap(), - size: 0, - executable: false, - digest: EMPTY_DIGEST.clone(), - }; - pub static ref FILE_A_B: IngestionEntry = IngestionEntry::Regular { - path: "a/b".parse().unwrap(), - size: 0, - executable: false, - digest: EMPTY_DIGEST.clone(), - }; - pub static ref FILE_A_B_C: IngestionEntry = IngestionEntry::Regular { - path: "a/b/c".parse().unwrap(), - size: 0, - executable: false, - digest: EMPTY_DIGEST.clone(), - }; - } + pub static EMPTY_DIGEST: LazyLock<B3Digest> = + LazyLock::new(|| blake3::hash(&[]).as_bytes().into()); + pub static DIR_A: LazyLock<IngestionEntry> = LazyLock::new(|| IngestionEntry::Dir { + path: "a".parse().unwrap(), + }); + pub static DIR_B: LazyLock<IngestionEntry> = LazyLock::new(|| IngestionEntry::Dir { + path: "b".parse().unwrap(), + }); + pub static DIR_A_B: LazyLock<IngestionEntry> = LazyLock::new(|| IngestionEntry::Dir { + path: "a/b".parse().unwrap(), + }); + pub static FILE_A: LazyLock<IngestionEntry> = LazyLock::new(|| IngestionEntry::Regular { + path: "a".parse().unwrap(), + size: 0, + executable: false, + digest: EMPTY_DIGEST.clone(), + }); + pub static FILE_A_B: LazyLock<IngestionEntry> = LazyLock::new(|| IngestionEntry::Regular { + path: "a/b".parse().unwrap(), + size: 0, + executable: false, + digest: EMPTY_DIGEST.clone(), + }); + pub static FILE_A_B_C: LazyLock<IngestionEntry> = LazyLock::new(|| IngestionEntry::Regular { + path: "a/b/c".parse().unwrap(), + size: 0, + executable: false, + digest: EMPTY_DIGEST.clone(), + }); #[rstest] #[case::implicit_directories(&[&*FILE_A_B_C], &[&*FILE_A_B_C, &*DIR_A_B, &*DIR_A])] |