label_depth for a leaf is always 1
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 6 Apr 2025 22:58:23 +0000 (15:58 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 6 Apr 2025 22:58:23 +0000 (15:58 -0700)
rust/pspp/src/output/pivot/mod.rs

index 6cdb9d7b7e01b7050c09f064afa7817a7eb3bc3d..7ce93dab3fc80fede41c1d62e7abce0ba7177659 100644 (file)
@@ -528,7 +528,6 @@ pub enum CategoryBuilder {
     Leaf {
         name: Box<Value>,
         class: Option<Class>,
-        label_depth: usize,
         extra_depth: usize,
     },
 }
@@ -553,13 +552,11 @@ impl CategoryBuilder {
             Self::Leaf {
                 name,
                 class,
-                label_depth,
                 extra_depth,
             } => {
                 let leaf = Arc::new(Leaf {
                     parent,
                     name,
-                    label_depth,
                     extra_depth,
                     class,
                 });
@@ -571,9 +568,7 @@ impl CategoryBuilder {
     fn assign_label_depth(&mut self, label_position: LabelPosition) {
         match self {
             CategoryBuilder::Group(group) => group.assign_label_depth(label_position, false),
-            CategoryBuilder::Leaf { label_depth, .. } => {
-                *label_depth = 1;
-            }
+            CategoryBuilder::Leaf { .. } => (),
         }
     }
     fn distribute_extra_depth(&mut self, extra: usize) {
@@ -585,13 +580,13 @@ impl CategoryBuilder {
     fn label_depth(&self) -> usize {
         match self {
             CategoryBuilder::Group(group) => group.label_depth,
-            CategoryBuilder::Leaf { label_depth, .. } => *label_depth,
+            CategoryBuilder::Leaf { .. } => 1,
         }
     }
     fn set_label_depth(&mut self, depth: usize) {
         match self {
             CategoryBuilder::Group(group) => group.label_depth = depth,
-            CategoryBuilder::Leaf { label_depth, .. } => *label_depth = depth,
+            CategoryBuilder::Leaf { .. } => (),
         }
     }
 }
@@ -607,7 +602,6 @@ impl From<Value> for CategoryBuilder {
         Self::Leaf {
             name: Box::new(name),
             class: None,
-            label_depth: 0,
             extra_depth: 0,
         }
     }
@@ -618,7 +612,6 @@ impl From<(Value, Class)> for CategoryBuilder {
         Self::Leaf {
             name: Box::new(name),
             class: Some(class),
-            label_depth: 0,
             extra_depth: 0,
         }
     }
@@ -679,7 +672,6 @@ impl PivotTableBuilder {
 pub struct Leaf {
     parent: Weak<Group>,
     name: Box<Value>,
-    label_depth: usize,
     extra_depth: usize,
 
     /// Default format for values in this category.
@@ -691,7 +683,6 @@ impl Leaf {
         Self {
             parent: Weak::new(),
             name: Box::new(name),
-            label_depth: 0,
             extra_depth: 0,
             class: None,
         }
@@ -788,7 +779,7 @@ impl CategoryTrait for Leaf {
     }
 
     fn label_depth(&self) -> usize {
-        self.label_depth
+        1
     }
 
     fn extra_depth(&self) -> usize {