macro_rules! udata {
(
$(#[$outer:meta])*
$vis:vis struct $name:ident {
$(
$fieldvis:vis $field:ident: $ty:ty
),*
}
$($rest:tt)*
) => {
#[repr(C)]
#[derive(
PartialEq,
PartialOrd,
Debug,
Default,
Copy,
Clone
)]
$(#[$outer])*
$vis struct $name {
$(
$fieldvis $field: $ty
),*
}
impl $name {
pub fn new( $($field: $ty),* ) -> $name {
$name {
$($field),*
}
}
}
udata!( $($rest)* );
};
() => ();
}
udata! {
pub struct Vector {
pub x: f32,
pub y: f32,
pub z: f32
}
pub struct Angle {
pub p: f32,
pub y: f32,
pub r: f32
}
}