icydb_schema/node/
newtype.rs

1use crate::prelude::*;
2
3///
4/// Newtype
5///
6
7#[derive(Clone, Debug, Serialize)]
8pub struct Newtype {
9    pub def: Def,
10    pub item: Item,
11
12    #[serde(default, skip_serializing_if = "Option::is_none")]
13    pub default: Option<Arg>,
14
15    pub ty: Type,
16}
17
18impl MacroNode for Newtype {
19    fn as_any(&self) -> &dyn std::any::Any {
20        self
21    }
22}
23
24impl TypeNode for Newtype {
25    fn ty(&self) -> &Type {
26        &self.ty
27    }
28}
29
30impl ValidateNode for Newtype {}
31
32impl VisitableNode for Newtype {
33    fn route_key(&self) -> String {
34        self.def.path()
35    }
36
37    fn drive<V: Visitor>(&self, v: &mut V) {
38        self.def.accept(v);
39        self.item.accept(v);
40        if let Some(node) = &self.default {
41            node.accept(v);
42        }
43        self.ty.accept(v);
44    }
45}