From 34083b7151101cd2ed0e865eb4e40a54fd2f1131 Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Fri, 20 Sep 2024 15:20:41 +0100 Subject: [PATCH] Use std::sync::LazyLock rather than once_cell. This was recently stabilised in Rust 1.80. Test: Treehugger Change-Id: I33a16bb1ad6c868c5d32ab72d08ce4e7f910300f --- libstats/pull_rust/Android.bp | 1 - libstats/pull_rust/stats_pull.rs | 7 +++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/libstats/pull_rust/Android.bp b/libstats/pull_rust/Android.bp index 69020267d..2a8939edb 100644 --- a/libstats/pull_rust/Android.bp +++ b/libstats/pull_rust/Android.bp @@ -61,7 +61,6 @@ rust_library { srcs: ["stats_pull.rs"], rustlibs: [ "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 b2bebcc4e..03929e3b2 100644 --- a/libstats/pull_rust/stats_pull.rs +++ b/libstats/pull_rust/stats_pull.rs @@ -14,13 +14,12 @@ //! A Rust interface for the StatsD pull API. -use once_cell::sync::Lazy; use statslog_rust_header::{Atoms, Stat, StatsError}; use statspull_bindgen::*; use std::collections::HashMap; use std::convert::TryInto; use std::os::raw::c_void; -use std::sync::Mutex; +use std::sync::{LazyLock, Mutex}; /// The return value of callbacks. pub type StatsPullResult = Vec>; @@ -107,8 +106,8 @@ impl Default for Metadata { } } -static COOKIES: Lazy StatsPullResult>>> = - Lazy::new(|| Mutex::new(HashMap::new())); +static COOKIES: LazyLock StatsPullResult>>> = + LazyLock::new(|| Mutex::new(HashMap::new())); /// # Safety ///