sway_ast/item/
item_configurable.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use crate::priv_prelude::*;

#[derive(Clone, Debug, Serialize)]
pub struct ItemConfigurable {
    pub configurable_token: ConfigurableToken,
    pub fields: Braces<Punctuated<Annotated<ConfigurableField>, CommaToken>>,
}

impl Spanned for ItemConfigurable {
    fn span(&self) -> Span {
        Span::join(self.configurable_token.span(), &self.fields.span())
    }
}

#[derive(Clone, Debug, Serialize)]
pub struct ConfigurableField {
    pub name: Ident,
    pub colon_token: ColonToken,
    pub ty: Ty,
    pub eq_token: EqToken,
    pub initializer: Expr,
}

impl Spanned for ConfigurableField {
    fn span(&self) -> Span {
        Span::join_all([
            self.name.span(),
            self.colon_token.span(),
            self.ty.span(),
            self.eq_token.span(),
            self.initializer.span(),
        ])
    }
}