From 9a8036402cc7e49124db7a553f881d968d6dbcab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20Dupr=C3=A9=20Bertoni?= Date: Thu, 15 Aug 2024 18:27:40 +0300 Subject: [PATCH] Statically assert FlashBuffer type parameters --- esp-storage/src/buffer.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/esp-storage/src/buffer.rs b/esp-storage/src/buffer.rs index fd378409ac7..fca60bfb2fe 100644 --- a/esp-storage/src/buffer.rs +++ b/esp-storage/src/buffer.rs @@ -20,8 +20,12 @@ pub union FlashBuffer { } impl FlashBuffer { - pub const fn uninit() -> Self { + const _CHECK: () = { assert!(N == M * 4); + }; + + pub const fn uninit() -> Self { + let _ = Self::_CHECK; Self { words: [MaybeUninit::uninit(); M], }