get rid of encodeddat
authorBen Pfaff <blp@cs.stanford.edu>
Mon, 28 Jul 2025 16:53:32 +0000 (09:53 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 28 Jul 2025 16:53:32 +0000 (09:53 -0700)
rust/pspp/src/data.rs
rust/pspp/src/format/display/mod.rs
rust/pspp/src/output/pivot/mod.rs

index 2bca7c2c9911fd96567a39b11abb832d55ba7872..727d47786b9df40498cce89bd5e5ca4be625fd80 100644 (file)
@@ -443,67 +443,6 @@ impl From<&str> for EncodedDatum {
     }
 }
 
-/// A borrowed [Datum] with a string encoding.
-#[derive(Copy, Clone)]
-pub enum EncodedDat<'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.
-        BorrowedEncodedString<'a>,
-    ),
-}
-
-impl<'a> EncodedDat<'a> {
-    /// 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<EncodedString<&'a BorrowedRawString>> {
-        match self {
-            Self::Number(_) => None,
-            Self::String(s) => Some(*s),
-        }
-    }
-
-    /*
-    /// Returns the string inside this datum as a mutable borrow, or `None` if
-    /// this is a numeric datum.
-    pub fn as_string_mut(&'a mut self) -> Option<EncodedString<&'a mut BorrowedRawString>> {
-        match self {
-            Self::Number(_) => None,
-            Self::String(s) => Some(*s),
-        }
-    }*/
-
-    pub fn eq_ignore_trailing_spaces<'b>(&self, other: EncodedDat<'b>) -> bool {
-        match (self, other) {
-            (Self::String(a), EncodedDat::String(b)) => a.eq_ignore_trailing_spaces(&b),
-            _ => *self == other,
-        }
-    }
-
-    pub fn quoted(&self) -> QuotedEncodedDatum<'a> {
-        todo!()
-    }
-}
-
 pub struct QuotedEncodedDatum<'a>(BorrowedEncodedDatum<'a>);
 
 impl Display for QuotedEncodedDatum<'_> {
@@ -516,31 +455,6 @@ impl Display for QuotedEncodedDatum<'_> {
     }
 }
 
-impl Display for EncodedDat<'_> {
-    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
-        match self {
-            Self::Number(None) => write!(f, "SYSMIS"),
-            Self::Number(Some(number)) => number.display_plain().fmt(f),
-            Self::String(string) => write!(f, "{string}"),
-        }
-    }
-}
-
-impl<'a> PartialEq for EncodedDat<'a> {
-    fn eq(&self, other: &Self) -> bool {
-        match (self, other) {
-            (Self::Number(Some(l0)), Self::Number(Some(r0))) => {
-                OrderedFloat(*l0) == OrderedFloat(*r0)
-            }
-            (Self::Number(None), Self::Number(None)) => true,
-            (Self::String(l0), Self::String(r0)) => l0 == r0,
-            _ => false,
-        }
-    }
-}
-
-impl<'a> Eq for EncodedDat<'a> {}
-
 /// A [Datum] that owns its string data (if any).
 pub type OwnedDatum = Datum<OwnedRawString>;
 
index fe69aba6c6c96bc4d1af6ea1039712a83031736f..236ada8b8a83aa6cd2e4c6744ea345a15a428234 100644 (file)
@@ -31,8 +31,7 @@ use smallvec::{Array, SmallVec};
 use crate::{
     calendar::{calendar_offset_to_gregorian, day_of_year, month_name, short_month_name},
     data::{
-        BorrowedEncodedDatum, BorrowedRawString, EncodedDat, EncodedDatum, EncodedString,
-        QuotedEncodedDatum,
+        BorrowedEncodedDatum, BorrowedRawString, EncodedDatum, EncodedString, QuotedEncodedDatum,
     },
     endian::{endian_to_smallvec, ToBytes},
     format::{Category, DateTemplate, Decimal, Format, NumberStyle, Settings, TemplateItem, Type},
index 1d6cd96d22fba473886e6986fa40e4dd80b0ad5e..f55df6c1412a89750dba33a649a0996bbef4fd75 100644 (file)
@@ -69,8 +69,7 @@ use tlo::parse_tlo;
 
 use crate::{
     data::{
-        BorrowedRawString, Datum, EncodedDat, EncodedDatum, EncodedString, OwnedEncodedDatum,
-        OwnedRawString,
+        BorrowedRawString, Datum, EncodedDatum, EncodedString, OwnedEncodedDatum, OwnedRawString,
     },
     dictionary::{VarType, Variable},
     format::{Decimal, Format, Settings as FormatSettings, Type, UncheckedFormat},