macro_rules! from_def_self {
($($ty:ty),+ $(,)?) => {
$(
impl $crate::FromDef for $ty {
type Def = Self;
fn from_def(
def: Self::Def,
_: &mut bevy_asset::LoadContext<'_>,
) -> Result<Self, crate::FromDefError> {
Ok(def)
}
}
)+
};
}
from_def_self![
(),
u8,
u16,
u32,
u64,
usize,
i8,
i16,
i32,
i64,
isize,
f32,
f64,
bool,
String,
std::time::Duration,
];
macro_rules! from_def_types {
(
mod $mod_name:ident,
feature = $feature:literal,
use $krate:path,
types = [$($ty:ident),+ $(,)?]
) => {
#[cfg(feature = $feature)]
mod $mod_name {
use $krate::{$($ty),+};
from_def_self![$($ty),+];
}
};
}
from_def_types!(
mod math,
feature = "math",
use bevy_math,
types = [
BVec2, BVec3, BVec3A, BVec4, BVec4A, EulerRot, IRect, IVec2, IVec3, IVec4, Isometry2d,
Isometry3d, Mat2, Mat3, Mat3A, Mat4, Quat, Ray2d, Ray3d, Rect, Rot2, URect, UVec2, UVec3,
UVec4, Vec2, Vec3, Vec3A, Vec4,
]
);
from_def_types!(
mod image,
feature = "image",
use bevy_image,
types = [TextureAtlasLayout]
);