1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
macro_rules! from_subtypes {
    ($type:ident,) => {};
    ($type:ident, $name:ident $(, $names:ident)* $(,)?) => {
        impl<'c> From<$name<'c>> for $type<'c> {
            fn from(value: $name<'c>) -> Self {
                unsafe { Self::from_raw(value.to_raw()) }
            }
        }

        from_subtypes!($type, $($names,)*);
    };
}

macro_rules! from_borrowed_subtypes {
    ($type:ident,) => {};
    ($type:ident, $name:ident $(, $names:ident)* $(,)?) => {
        impl<'c, 'a> From<$name<'c, 'a>> for $type<'c, 'a> {
            fn from(value: $name<'c, 'a>) -> Self {
                unsafe { Self::from_raw(value.to_raw()) }
            }
        }

        from_borrowed_subtypes!($type, $($names,)*);
    };
}