Rich-T-kid commented on code in PR #10438:
URL: https://github.com/apache/arrow-rs/pull/10438#discussion_r3809593410


##########
arrow-buffer/src/buffer/boolean.rs:
##########
@@ -610,6 +610,53 @@ impl BooleanBuffer {
         }
     }
 
+    /// Try to convert self into a [`BooleanBufferBuilder`] without copying.
+    ///
+    /// Reuses the underlying [`Buffer`] allocation if
+    /// 1. it is not shared (no other references to it exist) and
+    /// 2. the bit offset is zero
+    ///
+    /// Returns `Err(self)` if the allocation cannot be reused.
+    ///
+    /// # Example
+    /// ```
+    /// # use arrow_buffer::BooleanBuffer;
+    /// let buffer = BooleanBuffer::from(vec![true, false, true]);
+    /// // The buffer is not shared, so the builder reuses its allocation
+    /// let mut builder = buffer.try_into_builder().expect("buffer was not 
shared");
+    /// builder.append(false);
+    /// assert_eq!(builder.finish(), BooleanBuffer::from(vec![true, false, 
true, false]));
+    ///
+    /// // Conversion fails if the buffer is shared
+    /// let buffer = BooleanBuffer::from(vec![true, false, true]);
+    /// let shared = buffer.clone();
+    /// let buffer = buffer.try_into_builder().expect_err("buffer was shared");
+    /// # assert_eq!(buffer, shared);
+    /// ```
+    pub fn try_into_builder(self) -> Result<BooleanBufferBuilder, Self> {

Review Comment:
   its not super necessary. Maybe @/alamb  may include it in his pr 
https://github.com/apache/arrow-rs/pull/10397, so we can leave it out of this 
one



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to