tyrelr commented on a change in pull request #9304:
URL: https://github.com/apache/arrow/pull/9304#discussion_r563393453



##########
File path: rust/arrow/src/buffer.rs
##########
@@ -1188,6 +1209,57 @@ impl Drop for SetLenOnDrop<'_> {
     }
 }
 
+/// Creating a `MutableBuffer` instance by setting bits according to the 
boolean values
+impl std::iter::FromIterator<bool> for MutableBuffer {
+    fn from_iter<I>(iter: I) -> Self
+    where
+        I: IntoIterator<Item = bool>,
+    {
+        let mut iterator = iter.into_iter();
+        let mut result = {
+            let byte_capacity: usize = 
iterator.size_hint().0.saturating_add(7) / 8;
+            MutableBuffer::new(byte_capacity)
+        };
+
+        while let Some(value) = iterator.next() {
+            //we have the first bit of the byte
+            let mut exhausted = false;
+            let mut byte_accum: u8 = match value {

Review comment:
       After making that change, it seems like this could be achieved without 
requiring any changes to the previous Buffer API's: The byte-accumulation loop 
could be exposed as a ```PackedBoolIterator``` that wraps an 
```Iterator<Item=bool>```, exposing it as ``Iterator<Item=u8>()```.  I'm not 
sure if that would a better or worse approach...




----------------------------------------------------------------
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.

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


Reply via email to