Skip to content

Commit

Permalink
Allow const_assert_{eq,ne}! to take 2+ arguments
Browse files Browse the repository at this point in the history
They only took 2 arguments so that error messages can be added later
when `if` in `const` becomes stable. However, adding that will be a
breaking change due to a bump in minimum supported Rust version. So this
change is fine to have in the meantime, and then removed later once that
becomes how this macro is implemented.
  • Loading branch information
nvzqz committed Dec 29, 2019
1 parent ff7e334 commit 8b7c66b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/const_assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ macro_rules! const_assert {
/// ```
#[macro_export(local_inner_macros)]
macro_rules! const_assert_eq {
($x:expr, $y:expr $(,)?) => {
const_assert!($x == $y);
($x:expr, $($y:expr),+ $(,)?) => {
const_assert!($($x == $y)&&+);
};
}

Expand Down Expand Up @@ -120,7 +120,7 @@ macro_rules! const_assert_eq_usize {
/// ```
#[macro_export(local_inner_macros)]
macro_rules! const_assert_ne {
($x:expr, $y:expr $(,)?) => {
const_assert!($x != $y);
($x:expr, $($y:expr),+ $(,)?) => {
const_assert!($($x != $y)&&+);
};
}

0 comments on commit 8b7c66b

Please sign in to comment.