chloro-pn commented on code in PR #6178:
URL: https://github.com/apache/arrow-rs/pull/6178#discussion_r1709456107
##########
arrow-buffer/src/buffer/mutable.rs:
##########
@@ -668,6 +668,56 @@ impl MutableBuffer {
}
}
+impl<'a> MutableBuffer {
+ /// Creates a [`MutableBuffer`] from an `&[u8]` [`Iterator`] with a
trusted (upper) length.
+ /// Prefer this to `collect` whenever possible, as it is faster.
+ /// # Panic
+ /// This method will panic if `&u8.len()` != `item_size`.
+ /// # Example
+ /// ```
+ /// # use arrow_buffer::MutableBuffer;
+ /// # use arrow_buffer::ToByteSlice;
+ /// let iter = vec![[1_u8, 2].to_byte_slice(), [3_u8,
4].to_byte_slice()].into_iter();
+ /// let buf = unsafe {
+ /// MutableBuffer::from_trusted_len_iter_slice_u8(iter, 2)
+ /// };
+ /// assert_eq!(4, buf.len());
+ /// ```
+ /// # Safety
+ /// This method assumes that the iterator's size is correct and is
undefined behavior
Review Comment:
add
` /// # Panic`
` /// This method will panic if &[u8].len() != item_size.`
--
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]