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