From 8458106833024c06ca58856fcb871b3c41119c07 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Tue, 10 Mar 2020 21:19:23 -0400 Subject: [PATCH] Replace lazy_static! with once_cell::sync::Lazy As per https://github.com/connorskees/grass/commit/276134eb9362b8e0262cb948e8d0eb653dbd2739#r37745873, this allows us to avoid a macro call and get better autocompletion within the declaration. --- Cargo.toml | 2 +- src/builtin/mod.rs | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 99d3ede..07c49d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,10 +22,10 @@ path = "src/lib.rs" [dependencies] clap = { version = "2.33.0", optional = true } -lazy_static = "1.4.0" num-rational = "0.2.3" num-bigint = "0.2.6" num-traits = "0.2.11" +once_cell = "1.3.1" [features] default = ["commandline"] diff --git a/src/builtin/mod.rs b/src/builtin/mod.rs index cb61dc9..91e748b 100644 --- a/src/builtin/mod.rs +++ b/src/builtin/mod.rs @@ -1,4 +1,4 @@ -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::collections::HashMap; use crate::args::CallArgs; @@ -19,14 +19,12 @@ mod string; pub(crate) type Builtin = Box SassResult + Send + Sync>; -lazy_static! { - pub(crate) static ref GLOBAL_FUNCTIONS: HashMap = { - let mut m = HashMap::new(); - color::register(&mut m); - list::register(&mut m); - math::register(&mut m); - meta::register(&mut m); - string::register(&mut m); - m - }; -} +pub(crate) static GLOBAL_FUNCTIONS: Lazy> = Lazy::new(|| { + let mut m = HashMap::new(); + color::register(&mut m); + list::register(&mut m); + math::register(&mut m); + meta::register(&mut m); + string::register(&mut m); + m +});