summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2021-04-11 15:23:43 +0100
committerAlex Orlenko <zxteam@protonmail.com>2021-04-27 00:29:38 +0100
commitc19f12898d8a66c36cd0ddbcb869829ceed7a9f7 (patch)
treefa60c518ea420ed2e42de95b06323884db58f41c
parentc7541ef7d3f7487faf141d5c1e8c2ec25394294e (diff)
downloadmlua-c19f12898d8a66c36cd0ddbcb869829ceed7a9f7.zip
Replace lazy_static with once_cell
-rw-r--r--Cargo.toml2
-rw-r--r--src/util.rs8
2 files changed, 6 insertions, 4 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 2eac8bf..1299574 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -42,7 +42,7 @@ serialize = ["serde", "erased-serde"]
[dependencies]
mlua_derive = { version = "0.5", optional = true, path = "mlua_derive" }
bstr = { version = "0.2", features = ["std"], default_features = false }
-lazy_static = { version = "1.4" }
+once_cell = { version = "1.7" }
num-traits = { version = "0.2.14" }
futures-core = { version = "0.3.5", optional = true }
futures-task = { version = "0.3.5", optional = true }
diff --git a/src/util.rs b/src/util.rs
index e2c85ab..0d88b38 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -6,13 +6,15 @@ use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe};
use std::sync::{Arc, Mutex};
use std::{mem, ptr, slice};
+use once_cell::sync::Lazy;
+
use crate::error::{Error, Result};
use crate::ffi;
-lazy_static::lazy_static! {
+static METATABLE_CACHE: Lazy<Mutex<HashMap<TypeId, u8>>> = Lazy::new(|| {
// The capacity must(!) be greater than number of stored keys
- static ref METATABLE_CACHE: Mutex<HashMap<TypeId, u8>> = Mutex::new(HashMap::with_capacity(32));
-}
+ Mutex::new(HashMap::with_capacity(32))
+});
// Checks that Lua has enough free stack space for future stack operations. On failure, this will
// panic with an internal error message.