diff --git a/Cargo.toml b/Cargo.toml index 2abb9f9..69468a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ license = "Apache-2.0 OR MIT" documentation = "https://docs.rs/interchange" keywords = ["cortex-m", "nxp", "lpc"] categories = ["development-tools", "embedded"] +rust-version = "1.79" [target.'cfg(loom)'.dependencies] loom = "0.5" diff --git a/src/lib.rs b/src/lib.rs index 84409e1..3e4b144 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -331,9 +331,6 @@ pub struct Channel { } impl Channel { - #[cfg(not(loom))] - const CHANNEL_INIT: Channel = Self::new(); - // Loom's atomics are not const :/ #[cfg(not(loom))] pub const fn new() -> Self { @@ -889,7 +886,16 @@ impl Interchange { #[cfg(not(loom))] pub const fn new() -> Self { Self { - channels: [Channel::::CHANNEL_INIT; N], + channels: [const { Channel::new() }; N], + last_claimed: AtomicUsize::new(0), + } + } + + /// Create a new Interchange + #[cfg(loom)] + pub fn new() -> Self { + Self { + channels: core::array::from_fn(|_| Channel::new()), last_claimed: AtomicUsize::new(0), } } @@ -958,7 +964,6 @@ impl<'alloc, Rq, Rp> InterchangeRef<'alloc, Rq, Rp> { } } -#[cfg(not(loom))] impl Default for Interchange { fn default() -> Self { Self::new()