Show sizes in error output

This commit is contained in:
Oli Scherer 2022-07-11 10:34:01 +00:00
parent fef596f6a2
commit 9a204509d2

View File

@ -18,10 +18,12 @@ struct Transparent<T>(T);
struct NoNiche<T>(UnsafeCell<T>);
struct Size<const S: usize>;
// Overwriting the runtime assertion and making it a compile-time assertion
macro_rules! assert_size {
($a:ty, $b:literal) => {{
const _: () = assert!(std::mem::size_of::<$a>() == $b);
const _: Size::<$b> = Size::<{std::mem::size_of::<$a>()}>;
}};
}