use crate::ast::prelude::*;
#[test]
#[cfg(not(miri))]
fn ast_parse() {
rt::<ast::ItemEnum>("enum Foo { Bar(a), Baz(b), Empty() }");
rt::<ast::ItemEnum>("enum Foo { Bar(a), Baz(b), #[default_value = \"zombie\"] Empty() }");
rt::<ast::ItemEnum>(
"#[repr(Rune)] enum Foo { Bar(a), Baz(b), #[default_value = \"zombie\"] Empty() }",
);
rt::<ast::ItemEnum>("pub enum Color { Blue, Red, Green }");
rt::<ast::Fields>("( a, b, c )");
rt::<ast::Fields>("{ a, b, c }");
rt::<ast::Fields>("( #[serde(default)] a, b, c )");
rt::<ast::Fields>("{ a, #[debug(skip)] b, c }");
}
#[derive(Debug, TryClone, PartialEq, Eq, Parse, ToTokens, Spanned)]
#[rune(parse = "meta_only")]
#[non_exhaustive]
pub struct ItemEnum {
#[rune(iter, meta)]
pub attributes: Vec<ast::Attribute>,
#[rune(option, meta)]
pub visibility: ast::Visibility,
pub enum_token: T![enum],
pub name: ast::Ident,
pub variants: ast::Braced<ItemVariant, T![,]>,
}
item_parse!(Enum, ItemEnum, "enum item");
#[derive(Debug, TryClone, PartialEq, Eq, Parse, ToTokens, Spanned)]
#[non_exhaustive]
pub struct ItemVariant {
#[rune(iter)]
pub attributes: Vec<ast::Attribute>,
pub name: ast::Ident,
#[rune(iter)]
pub body: ast::Fields,
#[rune(skip)]
pub(crate) id: ItemId,
}