From: Ben Pfaff Date: Fri, 27 Dec 2024 18:36:48 +0000 (-0800) Subject: start code cleanup X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e048c68db1d64475df66528afb11a3b25fb82bad;p=pspp start code cleanup --- diff --git a/rust/pspp/src/cooked.rs b/rust/pspp/src/cooked.rs index 2cde42e32e..5954e2c88c 100644 --- a/rust/pspp/src/cooked.rs +++ b/rust/pspp/src/cooked.rs @@ -171,8 +171,6 @@ pub enum Error { TBD, } -type DictIndex = usize; - #[derive(Clone, Debug)] pub struct Headers { pub header: HeaderRecord, @@ -345,13 +343,13 @@ impl Headers { #[derive(Debug)] pub struct Metadata { - creation: NaiveDateTime, - endian: Endian, - compression: Option, - n_cases: Option, - product: String, - product_ext: Option, - version: Option<(i32, i32, i32)>, + pub creation: NaiveDateTime, + pub endian: Endian, + pub compression: Option, + pub n_cases: Option, + pub product: String, + pub product_ext: Option, + pub version: Option<(i32, i32, i32)>, } impl Metadata { @@ -660,7 +658,7 @@ pub fn decode( // Assign variable roles. for index in 0..dictionary.variables.len() { - let mut variable = dictionary.variables.get_index_mut2(index).unwrap(); + let variable = dictionary.variables.get_index_mut2(index).unwrap(); match variable.attributes.role() { Ok(role) => variable.role = role, Err(()) => warn(Error::TBD), @@ -780,7 +778,7 @@ impl MultipleResponseSet { return Err(Error::MixedMrSet(mr_set_name)); }; - let mr_type = MultipleResponseType::decode(&mr_set_name, &input.mr_type, min_width, warn)?; + let mr_type = MultipleResponseType::decode(&mr_set_name, &input.mr_type, min_width)?; Ok(MultipleResponseSet { name: mr_set_name, @@ -834,7 +832,6 @@ impl MultipleResponseType { mr_set: &Identifier, input: &raw::MultipleResponseType, min_width: VarWidth, - warn: &impl Fn(Error), ) -> Result { match input { raw::MultipleResponseType::MultipleDichotomy { value, labels } => { diff --git a/rust/pspp/src/lib.rs b/rust/pspp/src/lib.rs index 3548e020ee..ff105ecb82 100644 --- a/rust/pspp/src/lib.rs +++ b/rust/pspp/src/lib.rs @@ -1,4 +1,3 @@ -#[allow(unused_variables, unused_mut, dead_code)] pub mod cooked; pub mod dictionary; pub mod encoding; @@ -7,7 +6,6 @@ pub mod format; pub mod identifier; pub mod locale_charset; pub mod output; -#[allow(unused_variables, unused_mut, dead_code)] pub mod raw; pub mod sack; pub mod lex; diff --git a/rust/pspp/src/raw.rs b/rust/pspp/src/raw.rs index 3f2ef69fbc..c9f80d0b62 100644 --- a/rust/pspp/src/raw.rs +++ b/rust/pspp/src/raw.rs @@ -359,10 +359,6 @@ pub enum Compression { ZLib, } -trait Header { - fn offsets(&self) -> Range; -} - #[derive(Clone)] pub struct HeaderRecord where @@ -600,15 +596,6 @@ impl Decoder { } } -impl Header for HeaderRecord -where - S: Debug, -{ - fn offsets(&self) -> Range { - self.offsets.clone() - } -} - #[derive(Copy, Clone, PartialEq, Eq, Hash)] pub enum Magic { /// Regular system file. @@ -708,14 +695,6 @@ impl TryFrom for VarWidth { type RawValue = Value>; impl RawValue { - fn read(r: &mut R, var_type: VarType, endian: Endian) -> Result { - Ok(Self::from_raw( - &UntypedValue(read_bytes(r)?), - var_type, - endian, - )) - } - pub fn from_raw(raw: &UntypedValue, var_type: VarType, endian: Endian) -> Self { match var_type { VarType::String => Value::String(RawStr(raw.0)), @@ -1509,16 +1488,6 @@ where } } -impl Header for ValueLabelRecord -where - V: Debug, - S: Debug, -{ - fn offsets(&self) -> Range { - self.offsets.clone() - } -} - impl ValueLabelRecord where V: Debug, @@ -1716,15 +1685,6 @@ impl DocumentRecord { } } -impl Header for DocumentRecord -where - S: Debug, -{ - fn offsets(&self) -> Range { - self.offsets.clone() - } -} - trait ExtensionRecord { const SUBTYPE: u32; const SIZE: Option;