-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
A-assertionsProposals relating to assertions.Proposals relating to assertions.A-const-evalProposals relating to compile time evaluation (CTFE).Proposals relating to compile time evaluation (CTFE).T-libs-apiRelevant to the library API team, which will review and decide on the RFC.Relevant to the library API team, which will review and decide on the RFC.
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
rMazeiks, raviqqe, Kxuan, EFanZh, tower120 and 24 more
Metadata
Metadata
Assignees
Labels
A-assertionsProposals relating to assertions.Proposals relating to assertions.A-const-evalProposals relating to compile time evaluation (CTFE).Proposals relating to compile time evaluation (CTFE).T-libs-apiRelevant to the library API team, which will review and decide on the RFC.Relevant to the library API team, which will review and decide on the RFC.