refactor(tvix/nix-compat): remove use of lazy_static
This is now supported in the standard library via std::sync::LazyLock, but requires some manual shuffling around of code. I found at least one dead variable along the way, which I deleted. Change-Id: I8600c87c49078fb5ff72671994c77b919259e67b Reviewed-on: https://cl.tvl.fyi/c/depot/+/12608 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Autosubmit: tazjin <tazjin@tvl.su>
This commit is contained in:
parent
cb032b250e
commit
5faf7c9d7b
9 changed files with 92 additions and 110 deletions
|
|
@ -417,8 +417,8 @@ const DUMMY_VERIFYING_KEY: &str =
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use hex_literal::hex;
|
||||
use lazy_static::lazy_static;
|
||||
use pretty_assertions::assert_eq;
|
||||
use std::sync::LazyLock;
|
||||
use std::{io, str};
|
||||
|
||||
use crate::{
|
||||
|
|
@ -428,20 +428,18 @@ mod test {
|
|||
|
||||
use super::{Flags, NarInfo};
|
||||
|
||||
lazy_static! {
|
||||
static ref CASES: &'static [&'static str] = {
|
||||
let data = zstd::decode_all(io::Cursor::new(include_bytes!(
|
||||
"../../testdata/narinfo.zst"
|
||||
)))
|
||||
.unwrap();
|
||||
let data = str::from_utf8(Vec::leak(data)).unwrap();
|
||||
Vec::leak(
|
||||
data.split_inclusive("\n\n")
|
||||
.map(|s| s.strip_suffix('\n').unwrap())
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
};
|
||||
}
|
||||
static CASES: LazyLock<&'static [&'static str]> = LazyLock::new(|| {
|
||||
let data = zstd::decode_all(io::Cursor::new(include_bytes!(
|
||||
"../../testdata/narinfo.zst"
|
||||
)))
|
||||
.unwrap();
|
||||
let data = str::from_utf8(Vec::leak(data)).unwrap();
|
||||
Vec::leak(
|
||||
data.split_inclusive("\n\n")
|
||||
.map(|s| s.strip_suffix('\n').unwrap())
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
});
|
||||
|
||||
#[test]
|
||||
fn roundtrip() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue