Skip to content

Commit

Permalink
Use token tree in const_asset
Browse files Browse the repository at this point in the history
Instead of our current `const_assert` we can use a macro token tree and
call through to `assert`. Doing so makes the macro more general.
  • Loading branch information
tcharding committed Jul 6, 2024
1 parent 216129f commit a6e8fb1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internals/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,12 @@ macro_rules! debug_from_display {
}

/// Asserts a boolean expression at compile time.
// Copied from: https://internals.rust-lang.org/t/nicer-static-assertions/15986
#[macro_export]
macro_rules! const_assert {
($x:expr) => {{
const _: [(); 0 - !$x as usize] = [];
}};
($($tt:tt)*) => {
const _: () = assert!($($tt)*);
}
}

/// Derives `From<core::convert::Infallible>` for the given type.
Expand Down

0 comments on commit a6e8fb1

Please sign in to comment.