driver_interface/
_macro.rs

1#[macro_export]
2macro_rules! custom_type {
3    ($name:ident, $target:ty, $debug: expr) => {
4        #[derive(Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
5        #[repr(transparent)]
6        pub struct $name($target);
7
8        impl From<$target> for $name {
9            fn from(value: $target) -> Self {
10                Self(value)
11            }
12        }
13
14        impl From<$name> for $target {
15            fn from(value: $name) -> Self {
16                value.0
17            }
18        }
19
20        impl core::fmt::Debug for $name {
21            fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
22                write!(f, $debug, self.0)
23            }
24        }
25    };
26
27    ($name:ident, $target:ty) => {
28        $crate::custom_type!($name, $target, "{:?}")
29    };
30}