Closed
Description
I think asserts are a pretty common thing, especially in unsafe rust (checking sizes/alignments etc.)
Now with anonymous consts we can already do things like:
use std::mem::*;
#[macro_export]
macro_rules! static_assert {
($condition:expr) => {
const _: &() = &[()][1 - ($condition) as usize];
}
}
static_assert!(size_of::<usize>() == 8);
static_assert!(size_of::<*const u8>() == 8);
static_assert!(align_of::<*const u8>() >= align_of::<u128>());
static_assert!(5>3);
I propose to add macros like this to the core library, with the whole assert
/assert_eq
/assert_ne
facade.
I think these would be really useful