From aeb568c54bf41d60cba60fd465fb1951cac71b71 Mon Sep 17 00:00:00 2001 From: dAxpeDDa Date: Sun, 28 May 2023 21:07:31 +0200 Subject: [PATCH] Replace `lazy_static` with `once_cell` --- Cargo.toml | 2 +- src/imp/security_framework.rs | 7 ++++--- src/lib.rs | 4 ---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f63b0223..cab1d474 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ alpn = ["security-framework/alpn"] [target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies] security-framework = "2.0.0" security-framework-sys = "2.0.0" -lazy_static = "1.4.0" +once_cell = "1.0.0" libc = "0.2" tempfile = "3.1.0" diff --git a/src/imp/security_framework.rs b/src/imp/security_framework.rs index 9049c58b..03470147 100644 --- a/src/imp/security_framework.rs +++ b/src/imp/security_framework.rs @@ -1,4 +1,5 @@ extern crate libc; +extern crate once_cell; extern crate security_framework; extern crate security_framework_sys; extern crate tempfile; @@ -20,6 +21,8 @@ use std::str; use std::sync::Mutex; use std::sync::Once; +#[cfg(not(target_os = "ios"))] +use self::once_cell::sync::Lazy; #[cfg(not(target_os = "ios"))] use self::security_framework::os::macos::certificate::{PropertyType, SecCertificateExt}; #[cfg(not(target_os = "ios"))] @@ -38,9 +41,7 @@ use {Protocol, TlsAcceptorBuilder, TlsConnectorBuilder}; static SET_AT_EXIT: Once = Once::new(); #[cfg(not(target_os = "ios"))] -lazy_static! { - static ref TEMP_KEYCHAIN: Mutex> = Mutex::new(None); -} +static TEMP_KEYCHAIN: Lazy>> = Lazy::new(|| Mutex::new(None)); fn convert_protocol(protocol: Protocol) -> SslProtocol { match protocol { diff --git a/src/lib.rs b/src/lib.rs index bc907130..0e39c856 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -98,10 +98,6 @@ #![warn(missing_docs)] #![cfg_attr(docsrs, feature(doc_cfg))] -#[macro_use] -#[cfg(any(target_os = "macos", target_os = "ios"))] -extern crate lazy_static; - use std::any::Any; use std::error; use std::fmt;