Skip to content

Commit

Permalink
refactor(test_runner): replace lazy_static! with std::sync::LazyLock
Browse files Browse the repository at this point in the history
  • Loading branch information
yvt committed Nov 20, 2022
1 parent b6de1c0 commit 57184ad
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/r3_test_runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
15 changes: 8 additions & 7 deletions src/r3_test_runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<OptTarget> =
targets::TARGETS
.iter()
.map(|&(name, target)| OptTarget { name, target })
.collect();
}
use std::sync::LazyLock;
static VARIANTS: LazyLock<Vec<OptTarget>> = LazyLock::new(|| {
targets::TARGETS
.iter()
.map(|&(name, target)| OptTarget { name, target })
.collect()
});

&VARIANTS
}
Expand Down

0 comments on commit 57184ad

Please sign in to comment.