1
0
Fork 0
forked from wry/wry

autocommit 2022-03-02 14:24:07 CET

This commit is contained in:
Julian Orth 2022-03-02 14:24:07 +01:00
parent 0e9afcbfa5
commit aa0cb94143
30 changed files with 1059 additions and 123 deletions

View file

@ -330,6 +330,21 @@ macro_rules! assert_size_eq {
}};
}
macro_rules! assert_size_le {
($t:ty, $u:ty) => {{
struct AssertLeSize<T, U>(std::marker::PhantomData<T>, std::marker::PhantomData<U>);
impl<T, U> AssertLeSize<T, U> {
const VAL: usize = {
if std::mem::size_of::<T>() > std::mem::size_of::<U>() {
panic!("Left type has size larger than right type");
}
1
};
}
let _ = AssertLeSize::<$t, $u>::VAL;
}};
}
macro_rules! assert_align_eq {
($t:ty, $u:ty) => {{
struct AssertEqAlign<T, U>(std::marker::PhantomData<T>, std::marker::PhantomData<U>);