Skip to content

Commit

Permalink
Replace lazy_static with once_cell
Browse files Browse the repository at this point in the history
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] rust-lang/rust#109736

Change-Id: I21d343a38dbd25bb2d13f239f7fa3a2d7f20323e
  • Loading branch information
luca020400 committed Jan 22, 2024
1 parent 80b2bf1 commit cfa19bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion libstats/pull_rust/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand Down
7 changes: 3 additions & 4 deletions libstats/pull_rust/stats_pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
///
Expand Down

0 comments on commit cfa19bd

Please sign in to comment.