Skip to content

Commit 15a5bac

Browse files
committed
Switch boring from lazy_static to once_cell
1 parent 0952033 commit 15a5bac

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ cmake = "0.1"
2222
fslock = "0.2"
2323
bitflags = "1.0"
2424
foreign-types = "0.5"
25-
lazy_static = "1"
2625
libc = "0.2"
2726
hex = "0.4"
2827
rusty-hook = "^0.11"

boring/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pq-experimental = ["boring-sys/pq-experimental"]
3131
[dependencies]
3232
bitflags = { workspace = true }
3333
foreign-types = { workspace = true }
34-
lazy_static = { workspace = true }
34+
once_cell = { workspace = true }
3535
libc = { workspace = true }
3636
boring-sys = { workspace = true }
3737

boring/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@
8181
extern crate bitflags;
8282
#[macro_use]
8383
extern crate foreign_types;
84-
#[macro_use]
85-
extern crate lazy_static;
8684
extern crate boring_sys as ffi;
8785
extern crate libc;
8886

boring/src/ssl/mod.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
use crate::ffi;
6161
use foreign_types::{ForeignType, ForeignTypeRef, Opaque};
6262
use libc::{c_char, c_int, c_long, c_uchar, c_uint, c_void};
63+
use once_cell::sync::Lazy;
6364
use std::any::TypeId;
6465
use std::cmp;
6566
use std::collections::HashMap;
@@ -413,16 +414,12 @@ impl NameType {
413414
}
414415
}
415416

416-
lazy_static! {
417-
static ref INDEXES: Mutex<HashMap<TypeId, c_int>> = Mutex::new(HashMap::new());
418-
static ref SSL_INDEXES: Mutex<HashMap<TypeId, c_int>> = Mutex::new(HashMap::new());
419-
static ref SESSION_CTX_INDEX: Index<Ssl, SslContext> = Ssl::new_ex_index().unwrap();
420-
}
421-
417+
static INDEXES: Lazy<Mutex<HashMap<TypeId, c_int>>> = Lazy::new(|| Mutex::new(HashMap::new()));
418+
static SSL_INDEXES: Lazy<Mutex<HashMap<TypeId, c_int>>> = Lazy::new(|| Mutex::new(HashMap::new()));
419+
static SESSION_CTX_INDEX: Lazy<Index<Ssl, SslContext>> = Lazy::new(|| Ssl::new_ex_index().unwrap());
422420
#[cfg(feature = "rpk")]
423-
lazy_static! {
424-
static ref RPK_FLAG_INDEX: Index<SslContext, bool> = SslContext::new_ex_index().unwrap();
425-
}
421+
static RPK_FLAG_INDEX: Lazy<Index<SslContext, bool>> =
422+
Lazy::new(|| SslContext::new_ex_index().unwrap());
426423

427424
unsafe extern "C" fn free_data_box<T>(
428425
_parent: *mut c_void,

0 commit comments

Comments
 (0)