blob: 81d7803ec8ce0a862093cd5bdc7db5cd526910cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
enum Enum<T> { SVariant { v: T }, UVariant }
macro_rules! is_variant {
(TSVariant, ) => (!);
(SVariant, ) => (!);
(UVariant, $expr:expr) => (is_variant!(@check UVariant, {}, $expr));
(@check $variant:ident, $matcher:tt, $expr:expr) => (
assert!(if let Enum::$variant::<()> $matcher = $expr () { true } else { false },
);
);
}
fn main() {
is_variant!(UVariant, Enum::<()>::UVariant); //~ ERROR expected function
}
|