From 4fb2a559046b98be1e1b67464cd90442bbe76063 Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Fri, 19 Jan 2024 23:20:18 +0200 Subject: [PATCH] Make `Slot` and `SlotDuration` transparent (#2999) I have a use case that for safety requires all contained data structures to be `#[repr(C)]` or `#[repr(transparent)]` and it seemed like non-invasive change. --- substrate/primitives/consensus/slots/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/substrate/primitives/consensus/slots/src/lib.rs b/substrate/primitives/consensus/slots/src/lib.rs index b9a032c1bc..23cb7f7365 100644 --- a/substrate/primitives/consensus/slots/src/lib.rs +++ b/substrate/primitives/consensus/slots/src/lib.rs @@ -26,6 +26,7 @@ use sp_timestamp::Timestamp; /// Unit type wrapper that represents a slot. #[derive(Debug, Encode, MaxEncodedLen, Decode, Eq, Clone, Copy, Default, Ord, Hash, TypeInfo)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[repr(transparent)] pub struct Slot(u64); impl core::ops::Deref for Slot { @@ -135,6 +136,7 @@ impl From for u64 { Eq, TypeInfo, )] +#[repr(transparent)] pub struct SlotDuration(u64); impl SlotDuration {