userspace/macros/traits/from.rs
1#[macro_export]
2macro_rules! trait_implement_from {
3 ($name:ty, $inner:ty, $($t:ty),*) => {
4 $(
5 impl From<$name> for $t {
6 fn from(val: $name) -> $t {
7 val.0 as $t
8 }
9 }
10
11 impl From<$t> for $name {
12 fn from(v: $t) -> Self {
13 Self(v as $inner)
14 }
15 }
16 )*
17 }
18}
19pub use trait_implement_from;