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
26
27
28
29
30
31
32
33
34
use core::marker::PhantomData;
#[doc(no_inline)]
pub use r3::utils::Init;
macro_rules! If {
( if ($cond:expr) { $t:ty } else { $f:ty } ) => {
<crate::utils::Conditional<$t, $f, {$cond}> as crate::utils::TypeFn>::Output
};
( if ($cond:expr) { $t:ty } else if $($rest:tt)* ) => {
If! { if ($cond) { $t } else { If!{ if $($rest)* } } }
};
}
#[doc(hidden)]
pub trait TypeFn {
type Output;
}
#[doc(hidden)]
pub struct Conditional<T, F, const B: bool>(PhantomData<(T, F)>);
impl<T, F> TypeFn for Conditional<T, F, false> {
type Output = F;
}
impl<T, F> TypeFn for Conditional<T, F, true> {
type Output = T;
}