From 495954880d8c4e3b8c95aff0c6c45e560ca0054b Mon Sep 17 00:00:00 2001 From: Liang-Chi Hsieh Date: Tue, 18 Jun 2024 07:49:36 -0700 Subject: [PATCH] For review --- arrow-buffer/src/buffer/immutable.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/arrow-buffer/src/buffer/immutable.rs b/arrow-buffer/src/buffer/immutable.rs index ef74a4ed028b..2c743842fb05 100644 --- a/arrow-buffer/src/buffer/immutable.rs +++ b/arrow-buffer/src/buffer/immutable.rs @@ -74,14 +74,9 @@ impl Buffer { /// Returns the offset, in bytes, of `Self::ptr` to `Self::data` /// /// self.ptr and self.data can be different after slicing or advancing the buffer. - /// - /// # Safety - /// - /// This function is unsafe as it uses unsafe function `offset_from`. Under certain - /// conditions, this function can cause undefined behavior. See the documentation of - /// `offset_from` for more information. - pub unsafe fn ptr_offset(&self) -> usize { - self.ptr.offset_from(self.data.ptr().as_ptr()) as usize + pub fn ptr_offset(&self) -> usize { + // Safety: `ptr` is always in bounds of `data`. + unsafe { self.ptr.offset_from(self.data.ptr().as_ptr()) as usize } } /// Returns the pointer to the start of the buffer without the offset.