From 383092d1dd9926755ff8b7e017d31ad0961c8317 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 8 May 2024 14:01:41 +0200 Subject: [PATCH] Add constant assertions to check size of a region --- packages/std/src/memory.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/std/src/memory.rs b/packages/std/src/memory.rs index 38d8fd2378..d45ae8c44b 100644 --- a/packages/std/src/memory.rs +++ b/packages/std/src/memory.rs @@ -33,6 +33,11 @@ pub struct Region { _marker: PhantomData, } +const _: () = { + assert!(mem::size_of::>() == 12); + assert!(mem::size_of::>() == 12); +}; + impl Region { pub fn from_slice(slice: &[u8]) -> Self { unsafe { Self::from_parts(slice.as_ptr(), slice.len(), slice.len()) }