diff --git a/Cargo.lock b/Cargo.lock index e91f6f37..5fb5b5f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -839,9 +839,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.9.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "parking_lot" @@ -1188,7 +1188,7 @@ dependencies = [ "align-data", "bitflags", "fslock", - "lazy_static", + "once_cell", "trybuild", "which", ] diff --git a/Cargo.toml b/Cargo.toml index 89bfb808..ab0d0b1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,7 +80,7 @@ use_custom_libcxx = [] [dependencies] bitflags = "1.3.2" -lazy_static = "1.4.0" +once_cell = "1.17.1" [build-dependencies] fslock = "0.1.8" diff --git a/src/V8.rs b/src/V8.rs index 1a20970f..fe0b4c76 100644 --- a/src/V8.rs +++ b/src/V8.rs @@ -1,4 +1,5 @@ // Copyright 2019-2021 the Deno authors. All rights reserved. MIT license. +use once_cell::sync::Lazy; use std::ffi::CStr; use std::ffi::CString; use std::sync::Mutex; @@ -71,9 +72,8 @@ enum GlobalState { } use GlobalState::*; -lazy_static! { - static ref GLOBAL_STATE: Mutex = Mutex::new(Uninitialized); -} +static GLOBAL_STATE: Lazy> = + Lazy::new(|| Mutex::new(Uninitialized)); pub fn assert_initialized() { let global_state_guard = GLOBAL_STATE.lock().unwrap(); diff --git a/src/lib.rs b/src/lib.rs index c10ba73b..1255ee1c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,8 +26,6 @@ #[macro_use] extern crate bitflags; -#[macro_use] -extern crate lazy_static; mod array_buffer; mod array_buffer_view; diff --git a/tests/test_api.rs b/tests/test_api.rs index d95ffd97..47731c37 100644 --- a/tests/test_api.rs +++ b/tests/test_api.rs @@ -1,5 +1,5 @@ // Copyright 2019-2021 the Deno authors. All rights reserved. MIT license. -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::any::type_name; use std::cell::RefCell; use std::collections::hash_map::DefaultHasher; @@ -7480,9 +7480,7 @@ fn counter_lookup_callback() { unsafe impl Send for Name {} unsafe impl Send for Count {} - lazy_static! { - static ref MAP: Arc>> = Arc::default(); - } + static MAP: Lazy>>> = Lazy::new(Arc::default); // |name| points to a static zero-terminated C string. extern "C" fn callback(name: *const c_char) -> *mut i32 {