use crate::{
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, $nbits:expr, $Inner:ident) => {
unsafe impl<const FRAC: i32> Zeroable for $Fixed<FRAC> {}
unsafe impl<const FRAC: i32> Pod for $Fixed<FRAC> {}
unsafe impl<const FRAC: i32> Contiguous for $Fixed<FRAC> {
type Int = $Inner;
const MAX_VALUE: $Inner = $Inner::MAX;
const MIN_VALUE: $Inner = $Inner::MIN;
}
unsafe impl<const FRAC: i32> TransparentWrapper<$Inner> for $Fixed<FRAC> {}
unsafe impl<const FRAC: i32> Zeroable for Wrapping<$Fixed<FRAC>> {}
unsafe impl<const FRAC: i32> Pod for Wrapping<$Fixed<FRAC>> {}
unsafe impl<const FRAC: i32> Contiguous for Wrapping<$Fixed<FRAC>> {
type Int = $Inner;
const MAX_VALUE: $Inner = $Inner::MAX;
const MIN_VALUE: $Inner = $Inner::MIN;
}
unsafe impl<const FRAC: i32> TransparentWrapper<$Fixed<FRAC>> for Wrapping<$Fixed<FRAC>> {}
unsafe impl<const FRAC: i32> Zeroable for Unwrapped<$Fixed<FRAC>> {}
unsafe impl<const FRAC: i32> Pod for Unwrapped<$Fixed<FRAC>> {}
unsafe impl<const FRAC: i32> Contiguous for Unwrapped<$Fixed<FRAC>> {
type Int = $Inner;
const MAX_VALUE: $Inner = $Inner::MAX;
const MIN_VALUE: $Inner = $Inner::MIN;
}
unsafe impl<const FRAC: i32> TransparentWrapper<$Fixed<FRAC>> for Unwrapped<$Fixed<FRAC>> {}
};
}
unsafe_impl_traits! { FixedI8, 8, i8 }
unsafe_impl_traits! { FixedI16, 16, i16 }
unsafe_impl_traits! { FixedI32, 32, i32 }
unsafe_impl_traits! { FixedI64, 64, i64 }
unsafe_impl_traits! { FixedI128, 128, i128 }
unsafe_impl_traits! { FixedU8, 8, u8 }
unsafe_impl_traits! { FixedU16, 16, u16 }
unsafe_impl_traits! { FixedU32, 32, u32 }
unsafe_impl_traits! { FixedU64, 64, u64 }
unsafe_impl_traits! { FixedU128, 128, u128 }