From 2fd636abd4cca8e19d40820c9e8ad4b9e621be61 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 26 Mar 2025 17:11:44 -0700 Subject: [PATCH] work on styles --- rust/pspp/src/format/mod.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/rust/pspp/src/format/mod.rs b/rust/pspp/src/format/mod.rs index 5a345f7cfc..f49a2a5fa8 100644 --- a/rust/pspp/src/format/mod.rs +++ b/rust/pspp/src/format/mod.rs @@ -855,10 +855,15 @@ impl From<&Settings> for StyleParams { struct StyleSet(EnumMap); impl StyleSet { - fn new(f: impl Fn(StyleParams) -> NumberStyle) -> Self { - Self(EnumMap::from_fn(f)) + const fn new(f: impl Fn(StyleParams) -> NumberStyle) -> Self { + f(StyleParams { + decimal: Decimal::Comma, + leading_zero: false, + }); + todo!() + //Self(EnumMap::from_fn(f)) } - const fn get(&self, settings: &Settings) -> &NumberStyle { + fn get(&self, settings: &Settings) -> &NumberStyle { &self.0[settings.into()] } } @@ -987,10 +992,6 @@ impl NumberStyle { let prefix = Affix::new_static(prefix); let suffix = Affix::new_static(suffix); let neg_suffix = Affix::new_static(""); - let extra_bytes = neg_prefix.extra_bytes() - + prefix.extra_bytes() - + suffix.extra_bytes() - + neg_suffix.extra_bytes(); Self { neg_prefix, @@ -1000,7 +1001,7 @@ impl NumberStyle { decimal, grouping, leading_zero, - extra_bytes, + extra_bytes: 0, } } @@ -1029,14 +1030,14 @@ impl Affix { } } - fn new(s: String) -> Self { + pub fn new(s: String) -> Self { Self { width: s.width(), s: Cow::from(s), } } - const fn extra_bytes(&self) -> usize { + pub fn extra_bytes(&self) -> usize { self.s.len().checked_sub(self.width).unwrap() } } -- 2.30.2