sway_ast/item/
item_enum.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use crate::priv_prelude::*;

#[derive(Clone, Debug, Serialize)]
pub struct ItemEnum {
    pub visibility: Option<PubToken>,
    pub enum_token: EnumToken,
    pub name: Ident,
    pub generics: Option<GenericParams>,
    pub where_clause_opt: Option<WhereClause>,
    pub fields: Braces<Punctuated<Annotated<TypeField>, CommaToken>>,
}

impl Spanned for ItemEnum {
    fn span(&self) -> Span {
        let start = match &self.visibility {
            Some(pub_token) => pub_token.span(),
            None => self.enum_token.span(),
        };
        let end = self.fields.span();
        Span::join(start, &end)
    }
}