Skip to main content

xidl_parser/hir/
enum_dcl.rs

1use super::*;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Serialize, Deserialize, Clone)]
5pub struct EnumDcl {
6    pub annotations: Vec<Annotation>,
7    pub ident: String,
8    pub member: Vec<Enumerator>,
9}
10
11#[derive(Debug, Serialize, Deserialize, Clone)]
12pub struct Enumerator {
13    pub annotations: Vec<Annotation>,
14    pub ident: String,
15}
16
17impl From<crate::typed_ast::EnumDcl> for EnumDcl {
18    fn from(typed_ast: crate::typed_ast::EnumDcl) -> Self {
19        Self {
20            annotations: vec![],
21            ident: typed_ast.ident.0,
22            member: typed_ast.member.into_iter().map(Into::into).collect(),
23        }
24    }
25}
26
27impl From<crate::typed_ast::Enumerator> for Enumerator {
28    fn from(value: crate::typed_ast::Enumerator) -> Self {
29        Self {
30            annotations: expand_annotations(value.annotations),
31            ident: value.ident.0,
32        }
33    }
34}