emilk opened a new pull request, #10737:
URL: https://github.com/apache/arrow-rs/pull/10737

   # Which issue does this PR close?
   
   * Part of https://github.com/apache/arrow-rs/issues/10553
   
   # Rationale for this change
   
   `Buffer::slice`, `Buffer::advance` and `Buffer::slice_with_length` panic 
when asked for a range the buffer does not hold, and there is no way to ask 
without risking the panic. They are also the reason `ScalarBuffer::new` cannot 
get a `try_new` yet: two of its four panic causes come from these functions.
   
   `arrow-buffer` does not depend on `arrow-schema`, so it has no `ArrowError`. 
It uses one small error type per concern instead (`MutableBufferError`, 
`ParseI256Error`), so this adds one more in that style.
   
   # What changes are included in this PR?
   
   `OutOfBoundsError` (`Copy`, no allocation) and a `try_` variant for each of 
the three:
   
   * `Buffer::try_slice`
   * `Buffer::try_advance`, which leaves the buffer unchanged when it fails
   * `Buffer::try_slice_with_length`
   
   The panicking versions delegate to the fallible ones and keep their existing 
panic messages verbatim, since `arrow-array` and others assert on them.
   
   `Buffer::bit_slice` is left alone: its panic comes from two different paths 
and deserves its own change.
   
   Note this adds `arrow-buffer/src/error.rs`, the same file as #10736. 
Whichever lands first, I will rebase the other.
   
   # Are these changes tested?
   
   Yes, new tests for each error path, including `offset + length` overflowing 
`usize`. The existing `should_panic` tests are untouched, which is what pins 
the panic messages.
   
   # Are there any user-facing changes?
   
   New public API only, no breaking changes.


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

Reply via email to