bytemuck/derive.rs
1//! This module contains some helpers for the derive macros.
2
3/// A trait that can be used to convert the type of a byte array to an integer
4/// type of the same size.
5pub trait EnumTagIntegerBytes {
6 type Integer;
7}
8
9macro_rules! enum_tag_integer_impls {
10 ($($ty:ty),*) => {
11 $(
12 impl EnumTagIntegerBytes for [u8; core::mem::size_of::<$ty>()] {
13 type Integer = $ty;
14 }
15 )*
16 };
17}
18
19enum_tag_integer_impls!(u8, u16, u32, u64, u128);