From 794a952642317f7da1be2ea69e6865c55ea37be6 Mon Sep 17 00:00:00 2001 From: Luca Stefani Date: Mon, 22 Jan 2024 18:45:26 +0100 Subject: [PATCH] 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 --- libstats/pull_rust/Android.bp | 2 +- libstats/pull_rust/stats_pull.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libstats/pull_rust/Android.bp b/libstats/pull_rust/Android.bp index 4609e6bc4..69020267d 100644 --- a/libstats/pull_rust/Android.bp +++ b/libstats/pull_rust/Android.bp @@ -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", ], diff --git a/libstats/pull_rust/stats_pull.rs b/libstats/pull_rust/stats_pull.rs index d188b5fb5..b2bebcc4e 100644 --- a/libstats/pull_rust/stats_pull.rs +++ b/libstats/pull_rust/stats_pull.rs @@ -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 StatsPullResult>> = Mutex::new(HashMap::new()); -} +static COOKIES: Lazy StatsPullResult>>> = + Lazy::new(|| Mutex::new(HashMap::new())); /// # Safety ///