debian/missing-sources/bytemuck/src/derive.rs
raw| 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. |
| 5 | pub trait EnumTagIntegerBytes { |
| 6 | type Integer; |
| 7 | } |
| 8 | |
| 9 | macro_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 | |
| 19 | enum_tag_integer_impls!(u8, u16, u32, u64, u128); |