From 15b5d87512116749ac53c6ddc37d184adbd4eb1a Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 24 Jul 2025 18:49:38 -0700 Subject: [PATCH] get rid of dat --- rust/pspp/src/data.rs | 72 -------------------------------------- rust/pspp/src/sys/write.rs | 2 +- 2 files changed, 1 insertion(+), 73 deletions(-) diff --git a/rust/pspp/src/data.rs b/rust/pspp/src/data.rs index 883060ef82..9a84123de8 100644 --- a/rust/pspp/src/data.rs +++ b/rust/pspp/src/data.rs @@ -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, - ), - /// 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> { - 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 diff --git a/rust/pspp/src/sys/write.rs b/rust/pspp/src/sys/write.rs index 785c6cb242..0fa1edef2a 100644 --- a/rust/pspp/src/sys/write.rs +++ b/rust/pspp/src/sys/write.rs @@ -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, -- 2.30.2