From 9cf552e2409e009dc4ac74e7c7cd29eac0c2c11a Mon Sep 17 00:00:00 2001 From: junderw Date: Sat, 4 Dec 2021 13:04:13 +0900 Subject: [PATCH 1/2] Add a static immutable zero aligned type --- secp256k1-sys/src/types.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/secp256k1-sys/src/types.rs b/secp256k1-sys/src/types.rs index 208edf0..8746594 100644 --- a/secp256k1-sys/src/types.rs +++ b/secp256k1-sys/src/types.rs @@ -42,6 +42,9 @@ impl AlignedType { } } +/// A static zeroed out AlignedType for use in static assignments of [AlignedType; _] +pub static ZERO_ALIGNED: AlignedType = AlignedType([0u8; 16]); + #[cfg(all(feature = "std", not(rust_secp_no_symbol_renaming)))] pub(crate) const ALIGN_TO: usize = mem::align_of::(); From 5e6d0f1363438e24aceae46c3e0a7e5ce1027847 Mon Sep 17 00:00:00 2001 From: Jonathan Underwood Date: Thu, 23 Dec 2021 12:30:43 -0700 Subject: [PATCH 2/2] Switch to associated constant --- secp256k1-sys/src/types.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/secp256k1-sys/src/types.rs b/secp256k1-sys/src/types.rs index 8746594..aa397c7 100644 --- a/secp256k1-sys/src/types.rs +++ b/secp256k1-sys/src/types.rs @@ -40,10 +40,10 @@ impl AlignedType { pub fn zeroed() -> Self { AlignedType([0u8; 16]) } -} -/// A static zeroed out AlignedType for use in static assignments of [AlignedType; _] -pub static ZERO_ALIGNED: AlignedType = AlignedType([0u8; 16]); + /// A static zeroed out AlignedType for use in static assignments of [AlignedType; _] + const ZERO: AlignedType = AlignedType([0u8; 16]); +} #[cfg(all(feature = "std", not(rust_secp_no_symbol_renaming)))] pub(crate) const ALIGN_TO: usize = mem::align_of::();