From 1e2f09311c2218489b98dbca5369f75be2f8e063 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 26 Jul 2025 10:02:25 -0700 Subject: [PATCH] get rid of default generic parameter --- rust/pspp/src/data.rs | 24 ++++++++++++------------ rust/pspp/src/format/parse.rs | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/rust/pspp/src/data.rs b/rust/pspp/src/data.rs index e59ed6aee3..61cc4269e0 100644 --- a/rust/pspp/src/data.rs +++ b/rust/pspp/src/data.rs @@ -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 From<[u8; N]> for OwnedRawString { } } -impl From for OwnedRawString { - fn from(value: EncodedString) -> Self { +impl From 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> 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 { +pub struct EncodedString { /// 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> 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(&self, serializer: S) -> Result where S: serde::Serializer, diff --git a/rust/pspp/src/format/parse.rs b/rust/pspp/src/format/parse.rs index c960995c81..8b84a4e7e3 100644 --- a/rust/pspp/src/format/parse.rs +++ b/rust/pspp/src/format/parse.rs @@ -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, } -- 2.30.2