alamb commented on code in PR #7865:
URL: https://github.com/apache/arrow-rs/pull/7865#discussion_r2185946272


##########
parquet-variant/src/builder.rs:
##########
@@ -479,20 +572,29 @@ impl VariantBuilder {
         self
     }
 
+    // Returns validate_unique_fields because we can no longer reference self 
once this method returns.
+    fn parent_state(&mut self) -> (ParentState, bool) {
+        let state = ParentState::Variant {
+            buffer: &mut self.buffer,
+            metadata_builder: &mut self.metadata_builder,
+        };
+        (state, self.validate_unique_fields)
+    }
+
     /// Create an [`ListBuilder`] for creating [`Variant::List`] values.
     ///
     /// See the examples on [`VariantBuilder`] for usage.
     pub fn new_list(&mut self) -> ListBuilder {
-        ListBuilder::new(&mut self.buffer, &mut self.metadata_builder)
-            .with_validate_unique_fields(self.validate_unique_fields)
+        let (parent_state, validate_unique_fields) = self.parent_state();
+        ListBuilder::new(parent_state, validate_unique_fields)

Review Comment:
   If you want to avoid returning`validate_unique_fields` in a local field you 
could probably copy it by value with something like
   
   ```suggestion
           let validate_unique_fields = self.validate_unique_fields;
           let parent_state  = self.parent_state();
           ListBuilder::new(parent_state, validate_unique_fields)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to