tustvold commented on code in PR #4380:
URL: https://github.com/apache/arrow-rs/pull/4380#discussion_r1223320796


##########
arrow-buffer/src/buffer/boolean.rs:
##########
@@ -265,6 +265,30 @@ impl<'a> IntoIterator for &'a BooleanBuffer {
     }
 }
 
+impl From<&[bool]> for BooleanBuffer {
+    fn from(value: &[bool]) -> Self {
+        let mut builder = BooleanBufferBuilder::new(value.len());
+        builder.append_slice(value);
+        builder.finish()
+    }
+}
+
+impl From<Vec<bool>> for BooleanBuffer {
+    fn from(value: Vec<bool>) -> Self {
+        value.as_slice().into()
+    }
+}
+
+impl FromIterator<bool> for BooleanBuffer {
+    fn from_iter<T: IntoIterator<Item = bool>>(iter: T) -> Self {
+        let iter = iter.into_iter();
+        let (hint, _) = iter.size_hint();

Review Comment:
   Given the docs for size_hint state
   
   > size_hint() is primarily intended to be used for optimizations such as 
reserving space for the elements of the iterator
   
   I think it is reasonable to use the lower bound to pre-allocate, we also do 
this in other places



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