summary refs log tree commit diff
path: root/18/src/types.rs
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@gmail.com>2021-12-17 23:05:07 -0800
committerIrene Knapp <ireneista@gmail.com>2021-12-17 23:05:07 -0800
commit5679068cb93ac96439d3ed8410a2776cfeb3e09b (patch)
tree3279b012e7644e21c502d352caef4d8dc72e8b40 /18/src/types.rs
parentccd4d3b436259b86f2fa3b433cd19a7bd60752da (diff)
18
Diffstat (limited to '18/src/types.rs')
-rw-r--r--18/src/types.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/18/src/types.rs b/18/src/types.rs
new file mode 100644
index 0000000..6800fdc
--- /dev/null
+++ b/18/src/types.rs
@@ -0,0 +1,32 @@
+use std::fmt;
+
+
+#[derive(Clone)]
+pub enum Value {
+  Literal(i64),
+  Pair(Box<Pair>),
+}
+
+#[derive(Clone)]
+pub struct Pair {
+  pub left: Value,
+  pub right: Value,
+}
+
+
+impl fmt::Debug for Value {
+  fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
+    match self {
+      Value::Literal(n) => { write!(formatter, "{}", n) }
+      Value::Pair(pair) => { write!(formatter, "{:?}", pair) }
+    }
+  }
+}
+
+
+impl fmt::Debug for Pair {
+  fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
+    write!(formatter, "[{:?},{:?}]", self.left, self.right)
+  }
+}
+