From da4c2acf8944777e634eb33637d985bda1de278f Mon Sep 17 00:00:00 2001 From: Christian Beilschmidt Date: Tue, 7 Sep 2021 11:41:22 +0200 Subject: [PATCH] changed lazy_static to once_cell --- Cargo.toml | 2 +- src/config.rs | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 75af014f..2520d9ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ gdal-sys = { path = "gdal-sys", version = "^0.5"} ndarray = {version = "0.15", optional = true } chrono = { version = "0.4", optional = true } bitflags = "1.2" -lazy_static = "1.3" +once_cell = "1.8" [build-dependencies] gdal-sys = { path = "gdal-sys", version= "^0.5"} diff --git a/src/config.rs b/src/config.rs index b0107707..18e84ee3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -28,7 +28,7 @@ use libc::{c_char, c_void}; use crate::errors::Result; use crate::utils::_string; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::ffi::CString; use std::sync::Mutex; @@ -127,10 +127,9 @@ type CallbackType = dyn FnMut(CplErr, i32, &str) + 'static; static mut ERROR_CALLBACK: Option> = None; type CallbackTypeThreadSafe = dyn FnMut(CplErr, i32, &str) + 'static + Send; -lazy_static! { - static ref ERROR_CALLBACK_THREAD_SAFE: Mutex>> = - Mutex::new(None); -} + +static ERROR_CALLBACK_THREAD_SAFE: Lazy>>> = + Lazy::new(Default::default); /// Set a custom error handler for GDAL. /// Could be overwritten by setting a thread-local error handler.