Remove lazy_static dependency

Replaced by LazyLock
This commit is contained in:
gwenn 2024-07-27 07:38:47 +02:00
parent 499cc7bb98
commit d3e3c56474
3 changed files with 8 additions and 14 deletions

View File

@ -129,7 +129,6 @@ rusqlite-macros = { path = "rusqlite-macros", version = "0.3.0", optional = true
[dev-dependencies]
doc-comment = "0.3"
tempfile = "3.1.0"
lazy_static = "1.4"
regex = "1.5.5"
uuid = { version = "1.0", features = ["v4"] }
unicase = "2.6.0"

View File

@ -122,17 +122,15 @@ impl Connection {
#[cfg(test)]
mod test {
use lazy_static::lazy_static;
use std::sync::Mutex;
use std::sync::{LazyLock, Mutex};
use std::time::Duration;
use crate::{Connection, Result};
#[test]
fn test_trace() -> Result<()> {
lazy_static! {
static ref TRACED_STMTS: Mutex<Vec<String>> = Mutex::new(Vec::new());
}
static TRACED_STMTS: LazyLock<Mutex<Vec<String>>> =
LazyLock::new(|| Mutex::new(Vec::new()));
fn tracer(s: &str) {
let mut traced_stmts = TRACED_STMTS.lock().unwrap();
traced_stmts.push(s.to_owned());
@ -159,9 +157,8 @@ mod test {
#[test]
fn test_profile() -> Result<()> {
lazy_static! {
static ref PROFILED: Mutex<Vec<(String, Duration)>> = Mutex::new(Vec::new());
}
static PROFILED: LazyLock<Mutex<Vec<(String, Duration)>>> =
LazyLock::new(|| Mutex::new(Vec::new()));
fn profiler(s: &str, d: Duration) {
let mut profiled = PROFILED.lock().unwrap();
profiled.push((s.to_owned(), d));

View File

@ -4,13 +4,11 @@
#[cfg(feature = "trace")]
fn main() {
use lazy_static::lazy_static;
use std::os::raw::c_int;
use std::sync::Mutex;
use std::sync::{LazyLock, Mutex};
lazy_static! {
static ref LOGS_RECEIVED: Mutex<Vec<(c_int, String)>> = Mutex::new(Vec::new());
}
static LOGS_RECEIVED: LazyLock<Mutex<Vec<(c_int, String)>>> =
LazyLock::new(|| Mutex::new(Vec::new()));
fn log_handler(err: c_int, message: &str) {
let mut logs_received = LOGS_RECEIVED.lock().unwrap();