2023-08-15 05:58:33 -05:00
|
|
|
enum Enum<T> { SVariant { v: T }, UVariant }
|
2023-08-13 07:34:36 -05:00
|
|
|
|
|
|
|
macro_rules! is_variant {
|
|
|
|
(TSVariant, ) => (!);
|
|
|
|
(SVariant, ) => (!);
|
|
|
|
(UVariant, $expr:expr) => (is_variant!(@check UVariant, {}, $expr));
|
|
|
|
(@check $variant:ident, $matcher:tt, $expr:expr) => (
|
2023-08-15 05:58:33 -05:00
|
|
|
assert!(if let Enum::$variant::<()> $matcher = $expr () { true } else { false },
|
2023-08-13 07:34:36 -05:00
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
is_variant!(UVariant, Enum::<()>::UVariant); //~ ERROR expected function
|
|
|
|
}
|