rust: Introduce Datum::is_string, Datum::is_number.
authorBen Pfaff <blp@cs.stanford.edu>
Mon, 25 Aug 2025 02:30:28 +0000 (19:30 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 25 Aug 2025 02:30:28 +0000 (19:30 -0700)
rust/pspp/src/data.rs

index fa47025756f7d698711f273fbcd4ba56ac371bcb..0fb311cf5f100c1efd961adaab6844c6aced3931 100644 (file)
@@ -561,6 +561,14 @@ impl<B> Datum<B> {
         matches!(self, Self::Number(None))
     }
 
+    pub const fn is_number(&self) -> bool {
+        matches!(self, Self::Number(_))
+    }
+
+    pub const fn is_string(&self) -> bool {
+        matches!(self, Self::String(_))
+    }
+
     /// Returns the number inside this datum, or `None` if this is a string
     /// datum.
     pub fn as_number(&self) -> Option<Option<f64>> {