macros: Remove dependency to once_cell
Use OnceLock from std instead.
This commit is contained in:
parent
d82e2a02d5
commit
f2b58e5e07
@ -22,7 +22,6 @@ __internal_macro_expand = ["syn/visit-mut"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
once_cell = "1.13.0"
|
|
||||||
proc-macro-crate = "3.1.0"
|
proc-macro-crate = "3.1.0"
|
||||||
proc-macro2 = "1.0.24"
|
proc-macro2 = "1.0.24"
|
||||||
quote = "1.0.8"
|
quote = "1.0.8"
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
//! Methods and types for generating API endpoints.
|
//! Methods and types for generating API endpoints.
|
||||||
|
|
||||||
use std::{env, fs, path::Path};
|
use std::{env, fs, path::Path, sync::OnceLock};
|
||||||
|
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use proc_macro2::Span;
|
use proc_macro2::Span;
|
||||||
use serde::{de::IgnoredAny, Deserialize};
|
use serde::{de::IgnoredAny, Deserialize};
|
||||||
|
|
||||||
@ -29,9 +28,13 @@ fn ensure_feature_presence() -> Option<&'static syn::Error> {
|
|||||||
server: Option<IgnoredAny>,
|
server: Option<IgnoredAny>,
|
||||||
}
|
}
|
||||||
|
|
||||||
static RESULT: Lazy<Result<(), syn::Error>> = Lazy::new(|| {
|
static RESULT: OnceLock<Result<(), syn::Error>> = OnceLock::new();
|
||||||
let manifest_dir = env::var("CARGO_MANIFEST_DIR")
|
|
||||||
.map_err(|_| syn::Error::new(Span::call_site(), "Failed to read CARGO_MANIFEST_DIR"))?;
|
RESULT
|
||||||
|
.get_or_init(|| {
|
||||||
|
let manifest_dir = env::var("CARGO_MANIFEST_DIR").map_err(|_| {
|
||||||
|
syn::Error::new(Span::call_site(), "Failed to read CARGO_MANIFEST_DIR")
|
||||||
|
})?;
|
||||||
|
|
||||||
let manifest_file = Path::new(&manifest_dir).join("Cargo.toml");
|
let manifest_file = Path::new(&manifest_dir).join("Cargo.toml");
|
||||||
let manifest_bytes = fs::read_to_string(manifest_file)
|
let manifest_bytes = fs::read_to_string(manifest_file)
|
||||||
@ -59,7 +62,7 @@ fn ensure_feature_presence() -> Option<&'static syn::Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
})
|
||||||
|
.as_ref()
|
||||||
RESULT.as_ref().err()
|
.err()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user