2017-12-22 15:51:36 +03:00
|
|
|
#[macro_use]
|
|
|
|
extern crate enum_kind;
|
|
|
|
|
|
|
|
#[derive(Debug, Kind)]
|
|
|
|
#[kind(functions(is_a = "bool", prec = "u8"))]
|
|
|
|
pub enum Tokens {
|
|
|
|
#[kind(is_a)]
|
|
|
|
#[kind(prec = "7")]
|
|
|
|
A,
|
2018-03-09 10:56:43 +03:00
|
|
|
#[kind(prec = "6")] StructLike {},
|
|
|
|
#[kind(prec = "5")] TupleLike(u8),
|
2017-12-22 15:51:36 +03:00
|
|
|
|
|
|
|
#[kind(prec = "6")]
|
|
|
|
#[cfg(feature = "not-used")]
|
|
|
|
Unused,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn simple_bool() {
|
|
|
|
assert!(Tokens::A.is_a());
|
|
|
|
assert!(!Tokens::StructLike {}.is_a());
|
|
|
|
assert!(!Tokens::TupleLike(5).is_a());
|
|
|
|
}
|
2018-01-12 10:53:06 +03:00
|
|
|
|
|
|
|
#[derive(Debug, Kind)]
|
|
|
|
#[kind(functions(wanted = "bool"))]
|
|
|
|
pub enum Delegate {
|
2018-03-09 10:56:43 +03:00
|
|
|
#[kind(wanted)] Wanted,
|
|
|
|
#[kind(delegate)] May(Del),
|
2018-01-12 10:53:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Kind)]
|
|
|
|
#[kind(functions(wanted = "bool"))]
|
|
|
|
pub enum Del {
|
2018-03-09 10:56:43 +03:00
|
|
|
#[kind(wanted)] Yes,
|
2018-01-12 10:53:06 +03:00
|
|
|
No,
|
|
|
|
}
|