[pbs-devel] [PATCH proxmox 11/12] schema: remove lazy_static dependency
Maximiliano Sandoval
m.sandoval at proxmox.com
Tue Aug 13 12:57:08 CEST 2024
Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
---
proxmox-schema/Cargo.toml | 2 +-
proxmox-schema/src/const_regex.rs | 6 ++----
proxmox-schema/src/lib.rs | 8 --------
3 files changed, 3 insertions(+), 13 deletions(-)
diff --git a/proxmox-schema/Cargo.toml b/proxmox-schema/Cargo.toml
index f3aea3e1..ac4839e9 100644
--- a/proxmox-schema/Cargo.toml
+++ b/proxmox-schema/Cargo.toml
@@ -6,13 +6,13 @@ edition.workspace = true
license.workspace = true
repository.workspace = true
description = "proxmox api schema and validation"
+rust-version.workspace = true
exclude.workspace = true
[dependencies]
anyhow.workspace = true
const_format = { workspace = true, optional = true }
-lazy_static.workspace = true
regex.workspace = true
serde.workspace = true
serde_json.workspace = true
diff --git a/proxmox-schema/src/const_regex.rs b/proxmox-schema/src/const_regex.rs
index 3a5c2dab..8ddc41ab 100644
--- a/proxmox-schema/src/const_regex.rs
+++ b/proxmox-schema/src/const_regex.rs
@@ -5,7 +5,7 @@ use std::fmt;
/// The current Regex::new() function is not `const_fn`. Unless that
/// works, we use `ConstRegexPattern` to represent static regular
/// expressions. Please use the `const_regex` macro to generate
-/// instances of this type (uses lazy_static).
+/// instances of this type.
pub struct ConstRegexPattern {
/// This is only used for documentation and debugging
pub regex_string: &'static str,
@@ -47,9 +47,7 @@ macro_rules! const_regex {
$crate::ConstRegexPattern {
regex_string: $regex,
regex_obj: (|| -> &'static ::regex::Regex {
- $crate::semver_exempt::lazy_static! {
- static ref SCHEMA: ::regex::Regex = ::regex::Regex::new($regex).unwrap();
- }
+ static SCHEMA: std::sync::LazyLock<::regex::Regex> = std::sync::LazyLock::new(|| ::regex::Regex::new($regex).unwrap());
&SCHEMA
})
};
diff --git a/proxmox-schema/src/lib.rs b/proxmox-schema/src/lib.rs
index c91b5fd6..161f53ce 100644
--- a/proxmox-schema/src/lib.rs
+++ b/proxmox-schema/src/lib.rs
@@ -29,13 +29,5 @@ pub use schema::*;
pub mod upid;
-// const_regex uses lazy_static, but we otherwise don't need it, and don't want to force users to
-// have to write it out in their Cargo.toml as dependency, so we add a hidden re-export here which
-// is semver-exempt!
-#[doc(hidden)]
-pub mod semver_exempt {
- pub use lazy_static::lazy_static;
-}
-
#[cfg(feature = "api-types")]
pub mod api_types;
--
2.39.2
More information about the pbs-devel
mailing list