Skip to content

Commit

Permalink
Statically assert FlashBuffer type parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
DBLouis committed Aug 15, 2024
1 parent 285759a commit 9a80364
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion esp-storage/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ pub union FlashBuffer<const N: usize, const M: usize> {
}

impl<const N: usize, const M: usize> FlashBuffer<N, M> {
pub const fn uninit() -> Self {
const _CHECK: () = {
assert!(N == M * 4);
};

pub const fn uninit() -> Self {
let _ = Self::_CHECK;
Self {
words: [MaybeUninit::uninit(); M],
}
Expand Down

0 comments on commit 9a80364

Please sign in to comment.