From d6c620328c8594f1b575a1d79c98af94ca36f9a0 Mon Sep 17 00:00:00 2001 From: tottoto Date: Wed, 27 Mar 2024 22:33:55 +0900 Subject: [PATCH] replace once_cell Lazy with ordinary static Signed-off-by: tottoto --- Cargo.toml | 1 - kube-core/Cargo.toml | 1 - kube-core/src/resource.rs | 9 +++------ 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0c12782bd..e4c052f2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,6 @@ hyper-timeout = "0.5.1" json-patch = "1.0.0" jsonpath-rust = "0.5.0" k8s-openapi = { version = "0.21.0", default-features = false } -once_cell = "1.8.0" openssl = "0.10.36" parking_lot = "0.12.0" pem = "3.0.1" diff --git a/kube-core/Cargo.toml b/kube-core/Cargo.toml index 8fb7fb68d..0ce4277e6 100644 --- a/kube-core/Cargo.toml +++ b/kube-core/Cargo.toml @@ -32,7 +32,6 @@ thiserror.workspace = true form_urlencoded.workspace = true http.workspace = true json-patch = { workspace = true, optional = true } -once_cell.workspace = true chrono = { workspace = true, features = ["clock"] } schemars = { workspace = true, optional = true } k8s-openapi.workspace = true diff --git a/kube-core/src/resource.rs b/kube-core/src/resource.rs index 4b159b3bc..82a6f5570 100644 --- a/kube-core/src/resource.rs +++ b/kube-core/src/resource.rs @@ -216,10 +216,7 @@ pub trait ResourceExt: Resource { fn managed_fields_mut(&mut self) -> &mut Vec; } -// TODO: replace with ordinary static when BTreeMap::new() is no longer -// const-unstable. -use once_cell::sync::Lazy; -static EMPTY_MAP: Lazy> = Lazy::new(BTreeMap::new); +static EMPTY_MAP: BTreeMap = BTreeMap::new(); impl ResourceExt for K { fn name_unchecked(&self) -> String { @@ -251,7 +248,7 @@ impl ResourceExt for K { } fn labels(&self) -> &BTreeMap { - self.meta().labels.as_ref().unwrap_or(&*EMPTY_MAP) + self.meta().labels.as_ref().unwrap_or(&EMPTY_MAP) } fn labels_mut(&mut self) -> &mut BTreeMap { @@ -259,7 +256,7 @@ impl ResourceExt for K { } fn annotations(&self) -> &BTreeMap { - self.meta().annotations.as_ref().unwrap_or(&*EMPTY_MAP) + self.meta().annotations.as_ref().unwrap_or(&EMPTY_MAP) } fn annotations_mut(&mut self) -> &mut BTreeMap {