wleeaf commented on code in PR #11881:
URL: https://github.com/apache/arrow-rs/pull/11881#discussion_r4382070882
##########
arrow-buffer/src/buffer/immutable.rs:
##########
@@ -296,19 +296,31 @@ impl Buffer {
/// # Panics
/// Panics iff `(offset + length)` is larger than the existing length.
pub fn slice_with_length(&self, offset: usize, length: usize) -> Self {
- assert!(
- offset.saturating_add(length) <= self.length,
- "the offset of the new Buffer cannot exceed the existing length:
slice offset={offset} length={length} selflen={}",
- self.length
- );
+ self.try_slice_with_length(offset, length)
+ .unwrap_or_else(|e| panic!("{e}"))
Review Comment:
Close, but not quite the same message: `.unwrap()` would panic with ``called
`Result::unwrap()` on an `Err` value: InvalidArgumentError("...")`` (the
`Debug` form), while this keeps the panic message `slice_with_length` had
before. I can switch it to `.unwrap()` if you prefer the shorter code.
--
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]