Skip to content

Commit bd22868

Browse files
authored
Migrate from lazy_static to once_cell. (#44)
The Rust ecosystem is generally migrating away from lazy_static to once_cell, for example [here]. This patch updates openvino-sys from lazy_static to once_cell. [here]: clap-rs/clap#3828
1 parent 086e7d3 commit bd22868

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

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.

crates/openvino-sys/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ include = [
2525
links = "inference_engine_c_api"
2626

2727
[dependencies]
28-
lazy_static = {version = "1.4", optional = true }
28+
once_cell = {version = "1.12.0", optional = true }
2929
libloading = {version = "0.7", optional = true }
3030
openvino-finder = {version = "0.4.0", path = "../openvino-finder" }
3131

@@ -36,7 +36,7 @@ pretty_env_logger = "0.4"
3636
[features]
3737
# Linking features: `build.rs` will default to dynamic linking if none is selected.
3838
dynamic-linking = [] # Will find and bind to an OpenVINO shared library at compile time.
39-
runtime-linking = ["libloading", "lazy_static"] # Will bind to an OpenVINO shared library at runtime using `load`.
39+
runtime-linking = ["libloading", "once_cell"] # Will bind to an OpenVINO shared library at runtime using `load`.
4040

4141
[package.metadata.docs.rs]
4242
features = ["runtime-linking"]

crates/openvino-sys/src/linking/runtime.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ macro_rules! link {
1010
}
1111
)+
1212
) => (
13-
use lazy_static::lazy_static;
13+
use once_cell::sync::Lazy;
1414
use libloading;
1515
use std::path::PathBuf;
1616
use std::sync::Arc;
@@ -34,9 +34,7 @@ macro_rules! link {
3434
}
3535

3636
// `LIBRARY` holds the shared library reference.
37-
lazy_static!{
38-
static ref LIBRARY: RwLock<Option<Arc<SharedLibrary>>> = RwLock::new(None);
39-
}
37+
static LIBRARY: Lazy<RwLock<Option<Arc<SharedLibrary>>>> = Lazy::new(|| RwLock::new(None));
4038

4139
// Helper function for accessing the thread-local version of the library.
4240
fn with_library<T, F>(f: F) -> Option<T>

0 commit comments

Comments
 (0)