use crate::{
types::extra::{LeEqU128, LeEqU16, LeEqU32, LeEqU64, LeEqU8},
FixedI128, FixedI16, FixedI32, FixedI64, FixedI8, FixedU128, FixedU16, FixedU32, FixedU64,
FixedU8, Unwrapped, Wrapping,
};
use bytemuck::{Contiguous, Pod, TransparentWrapper, Zeroable};
macro_rules! unsafe_impl_traits {
($Fixed:ident, $LeEqU:ident, $Inner:ident) => {
unsafe impl<Frac> Zeroable for $Fixed<Frac> {}
unsafe impl<Frac: 'static> Pod for $Fixed<Frac> {}
unsafe impl<Frac: 'static> Contiguous for $Fixed<Frac> {
type Int = $Inner;
const MAX_VALUE: $Inner = $Inner::MAX;
const MIN_VALUE: $Inner = $Inner::MIN;
}
unsafe impl<Frac> TransparentWrapper<$Inner> for $Fixed<Frac> {}
unsafe impl<Frac: $LeEqU> Zeroable for Wrapping<$Fixed<Frac>> {}
unsafe impl<Frac: $LeEqU> Pod for Wrapping<$Fixed<Frac>> {}
unsafe impl<Frac: $LeEqU> Contiguous for Wrapping<$Fixed<Frac>> {
type Int = $Inner;
const MAX_VALUE: $Inner = $Inner::MAX;
const MIN_VALUE: $Inner = $Inner::MIN;
}
unsafe impl<Frac: $LeEqU> TransparentWrapper<$Fixed<Frac>> for Wrapping<$Fixed<Frac>> {}
unsafe impl<Frac: $LeEqU> Zeroable for Unwrapped<$Fixed<Frac>> {}
unsafe impl<Frac: $LeEqU> Pod for Unwrapped<$Fixed<Frac>> {}
unsafe impl<Frac: $LeEqU> Contiguous for Unwrapped<$Fixed<Frac>> {
type Int = $Inner;
const MAX_VALUE: $Inner = $Inner::MAX;
const MIN_VALUE: $Inner = $Inner::MIN;
}
unsafe impl<Frac: $LeEqU> TransparentWrapper<$Fixed<Frac>> for Unwrapped<$Fixed<Frac>> {}
};
}
unsafe_impl_traits! { FixedI8, LeEqU8, i8 }
unsafe_impl_traits! { FixedI16, LeEqU16, i16 }
unsafe_impl_traits! { FixedI32, LeEqU32, i32 }
unsafe_impl_traits! { FixedI64, LeEqU64, i64 }
unsafe_impl_traits! { FixedI128, LeEqU128, i128 }
unsafe_impl_traits! { FixedU8, LeEqU8, u8 }
unsafe_impl_traits! { FixedU16, LeEqU16, u16 }
unsafe_impl_traits! { FixedU32, LeEqU32, u32 }
unsafe_impl_traits! { FixedU64, LeEqU64, u64 }
unsafe_impl_traits! { FixedU128, LeEqU128, u128 }