about summary refs log tree commit diff
path: root/tvix/eval/src/value.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/value.rs')
-rw-r--r--tvix/eval/src/value.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/tvix/eval/src/value.rs b/tvix/eval/src/value.rs
index 037284b144b2..cbfff55b49e1 100644
--- a/tvix/eval/src/value.rs
+++ b/tvix/eval/src/value.rs
@@ -8,3 +8,28 @@ pub enum Value {
     Integer(i64),
     Float(f64),
 }
+
+impl Value {
+    pub fn is_number(&self) -> bool {
+        match self {
+            Value::Integer(_) => true,
+            Value::Float(_) => true,
+            _ => false,
+        }
+    }
+
+    pub fn type_of(&self) -> &'static str {
+        match self {
+            Value::Null => "null",
+            Value::Bool(_) => "bool",
+            Value::Integer(_) => "int",
+            Value::Float(_) => "float",
+        }
+    }
+}
+
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum NumberPair {
+    Floats(f64, f64),
+    Integer(i64, i64),
+}