Skip to content

Commit 6bc6e2e

Browse files
committed
Replace lazy_static with once_cell
1 parent 16eb018 commit 6bc6e2e

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

.github/main.workflow

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ action "Test all rust project" {
5353

5454
action "Smoke tests" {
5555
needs = "Test all rust project"
56-
uses = "docker://node:slim-buster"
56+
uses = "docker://node:buster-slim"
5757
runs = "./.github/entrypoint.sh"
5858
args = [
5959
"npm install",

Cargo.lock

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ edition = "2018"
1515
pest = "2"
1616
pest_derive = "2"
1717
# helper
18-
lazy_static = "1" # to define the global caches
1918
either = "1" # a workaround for iterator.filter that return Result<Vec, _>
2019
static_assertions = "0.3" # design-by-contract at compile time
2120

21+
[dependencies.once_cell] # to define the global caches
22+
version = "0.2"
23+
default-features = false # disable parking_lot
24+
2225
[badges]
2326
maintenance = { status = "actively-developed" }

packages/core/src/cache.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
//! Collection of cache variables which help detecting semantics error.
22
// TODO: 🤔 use hot reload https://crates.rs/crates/warmy when import statement is introduced
33
use crate::error::Error;
4-
use lazy_static::lazy_static;
4+
use once_cell::sync::Lazy;
55
use std::{collections::HashMap, sync::*};
66

77
// TODO: replace with https://github.com/rust-lang-nursery/lazy-static.rs/issues/111 when resolved
88
// 🤔 or is there any better way?
99
// pub static mut TRANSITION: Option<HashMap<Transition, &str>> = None; // doesn't work!
1010
// type LazyMut<T> = Mutex<Option<T>>;
11-
lazy_static! {
12-
static ref TRANSITION: Mutex<MapTransition> = Mutex::new(HashMap::new());
13-
static ref WARNING: RwLock<String> = RwLock::new(String::new());
14-
/*reserved for another caches*/
15-
}
11+
static TRANSITION: Lazy<Mutex<MapTransition>> = Lazy::new(|| Mutex::new(HashMap::new()));
12+
static WARNING: Lazy<RwLock<String>> = Lazy::new(|| RwLock::new(String::new()));
13+
/*reserved for another caches*/
1614

1715
/// Access cached transition safely
1816
pub fn transition<'a>() -> Result<MutexGuard<'a, MapTransition>, Error> {

0 commit comments

Comments
 (0)