From efb82b7b05785352d0003b565f15e73ca4e656a1 Mon Sep 17 00:00:00 2001 From: Anshul Gupta Date: Sat, 6 Jan 2024 22:52:08 -0800 Subject: [PATCH] Changes `make_channel!` macro to accept more types (#877) * Changes `make_channel!` macro to accept more types Changes `type` macro argument from `path` to `ty`, allowing more complex types like tuples, arrays, & pointers. See https://doc.rust-lang.org/reference/types.html#type-expressions. * Adds to `CHANGELOG.md` --- rtic-sync/CHANGELOG.md | 2 ++ rtic-sync/src/channel.rs | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/rtic-sync/CHANGELOG.md b/rtic-sync/CHANGELOG.md index ed10372177..0e5ab07adf 100644 --- a/rtic-sync/CHANGELOG.md +++ b/rtic-sync/CHANGELOG.md @@ -13,6 +13,8 @@ For each category, _Added_, _Changed_, _Fixed_ add new entries at the top! ### Fixed +- `make_channel` now accepts `Type` expressions instead of only `TypePath` expressions. + ## v1.1.1 - 2023-12-04 ### Fixed diff --git a/rtic-sync/src/channel.rs b/rtic-sync/src/channel.rs index 89a23af990..4f4f0c20ba 100644 --- a/rtic-sync/src/channel.rs +++ b/rtic-sync/src/channel.rs @@ -104,7 +104,7 @@ impl Channel { /// Creates a split channel with `'static` lifetime. #[macro_export] macro_rules! make_channel { - ($type:path, $size:expr) => {{ + ($type:ty, $size:expr) => {{ static mut CHANNEL: $crate::channel::Channel<$type, $size> = $crate::channel::Channel::new(); @@ -596,4 +596,9 @@ mod tests { make(); make(); } + + #[test] + fn tuple_channel() { + let _ = make_channel!((i32, u32), 10); + } }