Skip to content

Commit 1fe4631

Browse files
Remove workaround using inline consts (stable in 1.79)
1 parent ea956c2 commit 1fe4631

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ license = "Apache-2.0 OR MIT"
1010
documentation = "https://docs.rs/interchange"
1111
keywords = ["cortex-m", "nxp", "lpc"]
1212
categories = ["development-tools", "embedded"]
13+
rust-version = "1.79"
1314

1415
[target.'cfg(loom)'.dependencies]
1516
loom = "0.5"

src/lib.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,6 @@ pub struct Channel<Rq, Rp> {
331331
}
332332

333333
impl<Rq, Rp> Channel<Rq, Rp> {
334-
#[cfg(not(loom))]
335-
const CHANNEL_INIT: Channel<Rq, Rp> = Self::new();
336-
337334
// Loom's atomics are not const :/
338335
#[cfg(not(loom))]
339336
pub const fn new() -> Self {
@@ -889,7 +886,16 @@ impl<Rq, Rp, const N: usize> Interchange<Rq, Rp, N> {
889886
#[cfg(not(loom))]
890887
pub const fn new() -> Self {
891888
Self {
892-
channels: [Channel::<Rq, Rp>::CHANNEL_INIT; N],
889+
channels: [const { Channel::new() }; N],
890+
last_claimed: AtomicUsize::new(0),
891+
}
892+
}
893+
894+
/// Create a new Interchange
895+
#[cfg(loom)]
896+
pub fn new() -> Self {
897+
Self {
898+
channels: core::array::from_fn(|_| Channel::new()),
893899
last_claimed: AtomicUsize::new(0),
894900
}
895901
}
@@ -958,7 +964,6 @@ impl<'alloc, Rq, Rp> InterchangeRef<'alloc, Rq, Rp> {
958964
}
959965
}
960966

961-
#[cfg(not(loom))]
962967
impl<Rq, Rp, const N: usize> Default for Interchange<Rq, Rp, N> {
963968
fn default() -> Self {
964969
Self::new()

0 commit comments

Comments
 (0)