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