mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 02:31:03 +00:00
no_std compatibility for subxt-signer (#1477)
* subxt-signer no-std * impl error * address james comments * fix signer wasm tests * error impl for secret uri error
This commit is contained in:
+11
-16
@@ -7,34 +7,29 @@
|
||||
/// Use like:
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// once_static!{
|
||||
/// once_static_cloned!{
|
||||
/// /// Some documentation.
|
||||
/// fn foo() -> Vec<u8> {
|
||||
/// vec![1,2,3,4]
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
macro_rules! once_static {
|
||||
($($(#[$attr:meta])* $vis:vis fn $name:ident() -> $ty:ty { $expr:expr } )+) => {
|
||||
$(
|
||||
$(#[$attr])*
|
||||
$vis fn $name() -> &'static $ty {
|
||||
static VAR: std::sync::OnceLock<$ty> = std::sync::OnceLock::new();
|
||||
VAR.get_or_init(|| { $expr })
|
||||
}
|
||||
)+
|
||||
};
|
||||
}
|
||||
|
||||
/// Like `once_static!` but clones the item out of static storage. Useful if it
|
||||
///
|
||||
/// Clones the item out of static storage. Useful if it
|
||||
/// takes a while to create the item but cloning it is fairly cheap.
|
||||
macro_rules! once_static_cloned {
|
||||
($($(#[$attr:meta])* $vis:vis fn $name:ident() -> $ty:ty { $expr:expr } )+) => {
|
||||
$(
|
||||
$(#[$attr])*
|
||||
$vis fn $name() -> $ty {
|
||||
static VAR: std::sync::OnceLock<$ty> = std::sync::OnceLock::new();
|
||||
VAR.get_or_init(|| { $expr }).clone()
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "std")] {
|
||||
static VAR: std::sync::OnceLock<$ty> = std::sync::OnceLock::new();
|
||||
VAR.get_or_init(|| { $expr }).clone()
|
||||
} else {
|
||||
{ $expr }
|
||||
}
|
||||
}
|
||||
}
|
||||
)+
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user