Skip to content

Commit 15ce7f2

Browse files
committed
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] rust-lang/rust#109736 Test: m Change-Id: I21d343a38dbd25bb2d13f239f7fa3a2d7f20323e
1 parent 4ad3ba1 commit 15ce7f2

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

libstats/pull_rust/Android.bp

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ rust_library {
6060
crate_name: "statspull_rust",
6161
srcs: ["stats_pull.rs"],
6262
rustlibs: [
63-
"liblazy_static",
6463
"liblog_rust",
64+
"libonce_cell",
6565
"libstatslog_rust_header",
6666
"libstatspull_bindgen",
6767
],

libstats/pull_rust/stats_pull.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
//! A Rust interface for the StatsD pull API.
1616
17-
use lazy_static::lazy_static;
17+
use once_cell::sync::Lazy;
1818
use statslog_rust_header::{Atoms, Stat, StatsError};
1919
use statspull_bindgen::*;
2020
use std::collections::HashMap;
@@ -107,9 +107,8 @@ impl Default for Metadata {
107107
}
108108
}
109109

110-
lazy_static! {
111-
static ref COOKIES: Mutex<HashMap<i32, fn() -> StatsPullResult>> = Mutex::new(HashMap::new());
112-
}
110+
static COOKIES: Lazy<Mutex<HashMap<i32, fn() -> StatsPullResult>>> =
111+
Lazy::new(|| Mutex::new(HashMap::new()));
113112

114113
/// # Safety
115114
///

0 commit comments

Comments
 (0)