put the size check of the channel constructor in explicit const block

This commit is contained in:
Robin Mueller 2025-11-23 23:18:15 +01:00 committed by Emil Fresk
parent fbd472ec06
commit 8dee5b20ff

View file

@ -84,7 +84,7 @@ impl<T, const N: usize> Channel<T, N> {
/// Create a new channel. /// Create a new channel.
#[cfg(not(loom))] #[cfg(not(loom))]
pub const fn new() -> Self { pub const fn new() -> Self {
Self::size_check(); const { Self::size_check() };
Self { Self {
freeq: UnsafeCell::new(Deque::new()), freeq: UnsafeCell::new(Deque::new()),
readyq: UnsafeCell::new(Deque::new()), readyq: UnsafeCell::new(Deque::new()),
@ -99,7 +99,7 @@ impl<T, const N: usize> Channel<T, N> {
/// Create a new channel. /// Create a new channel.
#[cfg(loom)] #[cfg(loom)]
pub fn new() -> Self { pub fn new() -> Self {
Self::size_check(); const { Self::size_check() };
Self { Self {
freeq: UnsafeCell::new(Deque::new()), freeq: UnsafeCell::new(Deque::new()),
readyq: UnsafeCell::new(Deque::new()), readyq: UnsafeCell::new(Deque::new()),