Replace lazy_static with once_cell

Using lazy_static is now discouraged as unmaintained
and once_cell is the recommended replacement.

On top of that a similar implementation found in
once_cell is being tracked for inclusion under the
`lazy_cell` feature gate [0]

[0] https://github.com/rust-lang/rust/issues/109736

Test: m
Change-Id: I21d343a38dbd25bb2d13f239f7fa3a2d7f20323e
This commit is contained in:
Luca Stefani 2024-01-22 18:45:26 +01:00
parent 80b2bf16c9
commit 794a952642
2 changed files with 4 additions and 5 deletions

View file

@ -60,8 +60,8 @@ rust_library {
crate_name: "statspull_rust",
srcs: ["stats_pull.rs"],
rustlibs: [
"liblazy_static",
"liblog_rust",
"libonce_cell",
"libstatslog_rust_header",
"libstatspull_bindgen",
],

View file

@ -14,7 +14,7 @@
//! A Rust interface for the StatsD pull API.
use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use statslog_rust_header::{Atoms, Stat, StatsError};
use statspull_bindgen::*;
use std::collections::HashMap;
@ -107,9 +107,8 @@ impl Default for Metadata {
}
}
lazy_static! {
static ref COOKIES: Mutex<HashMap<i32, fn() -> StatsPullResult>> = Mutex::new(HashMap::new());
}
static COOKIES: Lazy<Mutex<HashMap<i32, fn() -> StatsPullResult>>> =
Lazy::new(|| Mutex::new(HashMap::new()));
/// # Safety
///