1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
/// # Example:
///
/// ```rust
/// use fregate::static_assert;
///
/// #[repr(i32)]
/// enum Enum {
/// One = 1,
/// Two,
/// Three,
/// }
///
/// static_assert!(Enum::One as i32 == 1);
/// ```
#[macro_export]
macro_rules! static_assert {
($cond:expr) => {
const _: () = assert!($cond);
};
}
/// # Example:
///
/// ```rust
/// use fregate::static_trait_assert;
///
/// #[repr(i32)]
/// enum Enum {
/// One,
/// Two,
/// Three,
/// }
///
/// impl From<Enum> for i32 {
/// fn from(value: Enum) -> Self {
/// value as i32
/// }
/// }
///
/// static_trait_assert!(Enum, Into<i32>);
/// ```
#[macro_export]
macro_rules! static_trait_assert {
($t:ty, $traits:path) => {
const fn type_trait_check()
where
$t: $traits,
{
}
const _: () = type_trait_check();
};
}