utilities/src/repr_c.rs

24 lines
495 B
Rust
Raw Normal View History

2023-02-20 09:14:23 +00:00
#[macro_export]
macro_rules! impl_reprc {
(
$(#[$meta: meta])*
$v:vis struct $struct_name:ident {
$( $(#[$field_meta:meta])* $member:ident : $t:ty, )+
}
) => {
#[repr(C)]
#[derive(Clone, DeriveReprC)]
$(#[$meta])*
$v struct $struct_name {
$(
$( #[$field_meta] )*
pub $member: $t,
)+
}
};
}
pub unsafe trait ReprC {
fn is_repr_c(&self) -> bool;
}