alamb commented on code in PR #11881:
URL: https://github.com/apache/arrow-rs/pull/11881#discussion_r4366753082
##########
arrow-buffer/src/buffer/immutable.rs:
##########
@@ -311,6 +311,17 @@ impl Buffer {
}
}
+ /// Returns a new [Buffer] that is a slice of this buffer starting at
`offset`,
+ /// with `length` bytes, or `None` if `(offset + length)` is larger than
the
+ /// existing length.
+ ///
+ /// This is the non-panicking version of [`Self::slice_with_length`], in
the same
+ /// way as [`slice::get`] is for indexing.
+ pub fn checked_slice_with_length(&self, offset: usize, length: usize) ->
Option<Self> {
+ (offset.saturating_add(length) <= self.length)
Review Comment:
I think this should return `Result` rather than option with a useful error
message (take from slice_with_lenght)
You could then haev slice_with_length simply return
`self.checked_slice_with_length().unwrap()`
--
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]