1use crate::prelude::*;
2
3#[derive(Clone, Debug, Serialize)]
8pub struct Map {
9 def: Def,
10 key: Item,
11 value: Value,
12 ty: Type,
13}
14
15impl Map {
16 #[must_use]
18 pub const fn new(def: Def, key: Item, value: Value, ty: Type) -> Self {
19 Self {
20 def,
21 key,
22 value,
23 ty,
24 }
25 }
26
27 #[must_use]
29 pub const fn def(&self) -> &Def {
30 &self.def
31 }
32
33 #[must_use]
35 pub const fn key(&self) -> &Item {
36 &self.key
37 }
38
39 #[must_use]
41 pub const fn value(&self) -> &Value {
42 &self.value
43 }
44
45 #[must_use]
47 pub const fn ty(&self) -> &Type {
48 &self.ty
49 }
50}
51
52impl MacroNode for Map {
53 fn as_any(&self) -> &dyn std::any::Any {
54 self
55 }
56}
57
58impl TypeNode for Map {
59 fn ty(&self) -> &Type {
60 self.ty()
61 }
62}
63
64impl ValidateNode for Map {}
65
66impl VisitableNode for Map {
67 fn route_key(&self) -> String {
68 self.def().path()
69 }
70
71 fn drive<V: Visitor>(&self, v: &mut V) {
72 self.def().accept(v);
73 self.key().accept(v);
74 self.value().accept(v);
75 self.ty().accept(v);
76 }
77}