emilk commented on code in PR #10759:
URL: https://github.com/apache/arrow-rs/pull/10759#discussion_r3880292164
##########
arrow-buffer/src/buffer/offset.rs:
##########
@@ -177,6 +177,42 @@ impl<O: ArrowNativeType> OffsetBuffer<O> {
Self(ScalarBuffer::from(offsets))
}
+ /// The first offset, i.e. the start of the first range.
+ ///
+ /// An [`OffsetBuffer`] is never empty, so this always returns an offset.
+ ///
+ /// ```
+ /// # use arrow_buffer::OffsetBuffer;
+ /// let offsets = OffsetBuffer::<i32>::from_lengths([1, 3, 5]);
+ /// assert_eq!(offsets.first(), 0);
+ /// assert_eq!(OffsetBuffer::<i32>::new_empty().first(), 0);
+ /// ```
+ #[inline]
+ pub fn first(&self) -> O {
+ self.0
+ .first()
+ .copied()
+ .expect("An `OffsetBuffer` is never empty")
+ }
Review Comment:
Can't deprecate `first()` - it is part of `&[T]` which this derefs into.
--
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]