From 57184ad718260cb0a284ed113dc6052a64d9b829 Mon Sep 17 00:00:00 2001 From: yvt Date: Sun, 20 Nov 2022 20:42:17 +0900 Subject: [PATCH] refactor(test_runner): replace `lazy_static!` with `std::sync::LazyLock` --- Cargo.lock | 1 - src/r3_test_runner/Cargo.toml | 1 - src/r3_test_runner/src/main.rs | 15 ++++++++------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8224dd01f2..c5398d3362 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2075,7 +2075,6 @@ dependencies = [ "futures-core", "goblin", "itertools", - "lazy_static", "log", "probe-rs", "probe-rs-rtt", diff --git a/src/r3_test_runner/Cargo.toml b/src/r3_test_runner/Cargo.toml index f7b72774c7..be1b0ac01b 100644 --- a/src/r3_test_runner/Cargo.toml +++ b/src/r3_test_runner/Cargo.toml @@ -16,7 +16,6 @@ futures-core = { version = "0.3.5" } probe-rs-rtt = { version = "0.12.0" } tokio-serial = { version = "5.4.1" } async-mutex = { version = "1.4.0" } -lazy_static = { version = "1.4.0" } env_logger = { version = "0.8.4" } serde_json = { version = "1.0.57" } serialport = { version = "4.0.0" } diff --git a/src/r3_test_runner/src/main.rs b/src/r3_test_runner/src/main.rs index 4ce0e9074e..394eba0db7 100644 --- a/src/r3_test_runner/src/main.rs +++ b/src/r3_test_runner/src/main.rs @@ -3,6 +3,7 @@ #![feature(must_not_suspend)] // `must_not_suspend` lint #![feature(lint_reasons)] #![feature(decl_macro)] // `macro` +#![feature(once_cell)] #![feature(pin_macro)] // `core::pin::pin!` #![warn(must_not_suspend)] use anyhow::{bail, Context}; @@ -98,13 +99,13 @@ struct OptTarget { impl clap::ValueEnum for OptTarget { fn value_variants<'a>() -> &'a [Self] { - lazy_static::lazy_static! { - static ref VARIANTS: Vec = - targets::TARGETS - .iter() - .map(|&(name, target)| OptTarget { name, target }) - .collect(); - } + use std::sync::LazyLock; + static VARIANTS: LazyLock> = LazyLock::new(|| { + targets::TARGETS + .iter() + .map(|&(name, target)| OptTarget { name, target }) + .collect() + }); &VARIANTS }