1use crate::ast::prelude::*;
2
3#[test]
4#[cfg(not(miri))]
5fn ast_parse() {
6 rt::<ast::ItemStatic>("static value = #{}");
7 rt::<ast::ItemStatic>("static value");
8}
9
10#[derive(Debug, TryClone, PartialEq, Eq, Parse, ToTokens, Spanned)]
12#[rune(parse = "meta_only")]
13#[non_exhaustive]
14pub struct ItemStatic {
15 #[rune(iter, meta)]
17 pub attributes: Vec<ast::Attribute>,
18 #[rune(option, meta)]
20 pub visibility: ast::Visibility,
21 #[rune(meta)]
23 pub static_token: T![static],
24 pub name: ast::Ident,
26 #[rune(iter)]
32 pub init: Option<ItemStaticInit>,
33 #[rune(skip)]
35 pub(crate) id: ItemId,
36}
37
38impl ItemStatic {}
39
40#[derive(Debug, TryClone, PartialEq, Eq, Parse, ToTokens, Spanned)]
42#[non_exhaustive]
43pub struct ItemStaticInit {
44 pub eq: T![=],
46 pub expr: ast::Expr,
49}
50
51impl Peek for ItemStaticInit {
52 fn peek(p: &mut Peeker<'_>) -> bool {
53 matches!(p.nth(0), K![=])
54 }
55}
56
57item_parse!(Static, ItemStatic, "static item");