get rid of dat
authorBen Pfaff <blp@cs.stanford.edu>
Fri, 25 Jul 2025 01:49:38 +0000 (18:49 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Fri, 25 Jul 2025 01:49:38 +0000 (18:49 -0700)
rust/pspp/src/data.rs
rust/pspp/src/sys/write.rs

index 883060ef82667d9cfbcb96c5a6202e6b53feae3b..9a84123de8e06b30c5a75e93ed5cc22983c5b594 100644 (file)
@@ -278,15 +278,6 @@ impl EncodedDatum {
         }
     }
 
-    pub fn as_raw(&self) -> Dat<'_> {
-        match self {
-            EncodedDatum::Number(number) => Dat::Number(*number),
-            EncodedDatum::String(encoded_string) => {
-                Dat::String(RawStr::from_bytes(encoded_string.as_bytes()))
-            }
-        }
-    }
-
     /// Constructs a new numerical [EncodedDatum] for the system-missing value.
     pub const fn sysmis() -> Self {
         Self::Number(None)
@@ -507,69 +498,6 @@ impl<'a> PartialEq for EncodedDat<'a> {
 
 impl<'a> Eq for EncodedDat<'a> {}
 
-/// A borrowed [Datum].
-#[derive(Clone)]
-pub enum Dat<'a> {
-    /// A numeric value.
-    Number(
-        /// A number, or `None` for the system-missing value.
-        Option<f64>,
-    ),
-    /// A string value.
-    String(
-        /// The value, in the variable's encoding.
-        &'a RawStr,
-    ),
-}
-
-impl Dat<'_> {
-    /// Constructs a new numerical [Datum] for the system-missing value.
-    pub const fn sysmis() -> Self {
-        Self::Number(None)
-    }
-
-    /// Returns the number inside this datum, or `None` if this is a string
-    /// datum.
-    pub fn as_number(&self) -> Option<Option<f64>> {
-        match self {
-            Self::Number(number) => Some(*number),
-            Self::String(_) => None,
-        }
-    }
-
-    /// Returns the string inside this datum, or `None` if this is a numeric
-    /// datum.
-    pub fn as_string(&self) -> Option<&RawStr> {
-        match self {
-            Self::Number(_) => None,
-            Self::String(s) => Some(s),
-        }
-    }
-
-    pub fn as_encoded<'a>(&'a self, encoding: &'static Encoding) -> EncodedDat<'a> {
-        match self {
-            Self::Number(number) => EncodedDat::Number(*number),
-            Self::String(raw_string) => EncodedDat::String(raw_string.as_encoded(encoding)),
-        }
-    }
-
-    /// Returns the [VarType] corresponding to this datum.
-    pub fn var_type(&self) -> VarType {
-        match self {
-            Self::Number(_) => VarType::Numeric,
-            Self::String(_) => VarType::String,
-        }
-    }
-
-    /// Returns the [VarWidth] corresponding to this datum.
-    pub fn width(&self) -> VarWidth {
-        match self {
-            Self::Number(_) => VarWidth::Numeric,
-            Self::String(s) => VarWidth::String(s.len().try_into().unwrap()),
-        }
-    }
-}
-
 /// The value of a [Variable](crate::dictionary::Variable).
 #[derive(Clone)]
 pub enum Datum<B>
index 785c6cb24219a9136c010f514f76153c7a5e7b90..0fa1edef2ad630f5bee2745aaddcaa244e7984fb 100644 (file)
@@ -17,7 +17,7 @@ use itertools::zip_eq;
 use smallvec::SmallVec;
 
 use crate::{
-    data::{Dat, Datum, EncodedDatum, RawStr, RawString},
+    data::{Datum, EncodedDatum, RawStr, RawString},
     dictionary::{
         Alignment, Attributes, CategoryLabels, Dictionary, Measure, MultipleResponseType,
         ValueLabels, VarWidth,