get rid of default generic parameter
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 26 Jul 2025 17:02:25 +0000 (10:02 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 26 Jul 2025 17:02:25 +0000 (10:02 -0700)
rust/pspp/src/data.rs
rust/pspp/src/format/parse.rs

index e59ed6aee376948d566a0e27339d32ea5d10c608..61cc4269e0674b1099b9dbe0de46a6bdefcca77b 100644 (file)
@@ -137,7 +137,7 @@ impl OwnedRawString {
         while self.0.pop_if(|c| *c == b' ').is_some() {}
     }
 
-    pub fn with_encoding(self, encoding: &'static Encoding) -> EncodedString {
+    pub fn with_encoding(self, encoding: &'static Encoding) -> OwnedEncodedString {
         EncodedString {
             bytes: self,
             encoding,
@@ -222,8 +222,8 @@ impl<const N: usize> From<[u8; N]> for OwnedRawString {
     }
 }
 
-impl From<EncodedString> for OwnedRawString {
-    fn from(value: EncodedString) -> Self {
+impl From<OwnedEncodedString> for OwnedRawString {
+    fn from(value: OwnedEncodedString) -> Self {
         value.bytes
     }
 }
@@ -285,7 +285,7 @@ pub enum EncodedDatum {
     /// A string value.
     String(
         /// The value, in the variable's encoding.
-        EncodedString,
+        OwnedEncodedString,
     ),
 }
 
@@ -313,7 +313,7 @@ impl EncodedDatum {
 
     /// Returns the string inside this datum, or `None` if this is a numeric
     /// datum.
-    pub fn as_string(&self) -> Option<&EncodedString> {
+    pub fn as_string(&self) -> Option<&OwnedEncodedString> {
         match self {
             Self::Number(_) => None,
             Self::String(s) => Some(s),
@@ -322,7 +322,7 @@ impl EncodedDatum {
 
     /// Returns the string inside this datum as a mutable borrow, or `None` if
     /// this is a numeric datum.
-    pub fn as_string_mut(&mut self) -> Option<&mut EncodedString> {
+    pub fn as_string_mut(&mut self) -> Option<&mut OwnedEncodedString> {
         match self {
             Self::Number(_) => None,
             Self::String(s) => Some(s),
@@ -416,7 +416,7 @@ impl From<Option<f64>> for EncodedDatum {
 
 impl From<&str> for EncodedDatum {
     fn from(value: &str) -> Self {
-        Self::String(EncodedString::from(value))
+        Self::String(OwnedEncodedString::from(value))
     }
 }
 
@@ -431,7 +431,7 @@ pub enum EncodedDat<'a> {
     /// A string value.
     String(
         /// The value, in the variable's encoding.
-        EncodedString<&'a BorrowedRawString>,
+        BorrowedEncodedString<'a>,
     ),
 }
 
@@ -875,7 +875,7 @@ pub type BorrowedEncodedString<'a> = EncodedString<&'a BorrowedRawString>;
 ///
 /// The string is not guaranteed to be valid in the encoding.
 #[derive(Copy, Clone, Debug)]
-pub struct EncodedString<R = OwnedRawString> {
+pub struct EncodedString<R> {
     /// The bytes of the string.
     bytes: R,
 
@@ -962,7 +962,7 @@ where
     }
 }
 
-impl EncodedString {
+impl OwnedEncodedString {
     pub fn resize(&mut self, new_len: usize) -> Result<(), ()> {
         match new_len.cmp(&self.len()) {
             Ordering::Less => {
@@ -992,7 +992,7 @@ impl<'a> From<BorrowedEncodedString<'a>> for OwnedEncodedString {
     }
 }
 
-impl From<&str> for EncodedString {
+impl From<&str> for OwnedEncodedString {
     fn from(value: &str) -> Self {
         Self {
             bytes: RawString(value.into()),
@@ -1016,7 +1016,7 @@ impl<'a> From<&'a String> for BorrowedEncodedString<'a> {
     }
 }
 
-impl Serialize for EncodedString {
+impl Serialize for OwnedEncodedString {
     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     where
         S: serde::Serializer,
index c960995c81b7ed59594e1d5f8903e90118975652..8b84a4e7e39b3a0241ae466a93ed75c89f613a8e 100644 (file)
@@ -16,7 +16,7 @@
 
 use crate::{
     calendar::{calendar_gregorian_to_offset, DateError},
-    data::{BorrowedEncodedString, Datum, EncodedString, OwnedDatum},
+    data::{BorrowedEncodedString, Datum, OwnedDatum, OwnedEncodedString},
     endian::{Endian, Parse},
     format::{DateTemplate, Decimals, Settings, TemplateItem, Type},
     settings::{EndianSettings, Settings as PsppSettings},
@@ -32,7 +32,7 @@ use thiserror::Error as ThisError;
 #[derive(Clone, Debug)]
 pub struct ParseError {
     type_: Type,
-    input: EncodedString,
+    input: OwnedEncodedString,
     kind: ParseErrorKind,
 }