diff --git a/arrow-buffer/src/buffer/mutable.rs b/arrow-buffer/src/buffer/mutable.rs index 51a7b783e0b3..e99f755485de 100644 --- a/arrow-buffer/src/buffer/mutable.rs +++ b/arrow-buffer/src/buffer/mutable.rs @@ -93,7 +93,7 @@ pub struct MutableBuffer { allocator: A, } -/// Constructors under default allocator +/// Constructors when using the default allocator [`Global`](std::alloc::Global) impl MutableBuffer { /// Allocate a new [MutableBuffer] with initial capacity to be at least `capacity`. /// @@ -226,6 +226,31 @@ impl MutableBuffer { buffer.truncate(bit_util::ceil(len, 8)); buffer } + + #[deprecated( + since = "2.0.0", + note = "This method is deprecated in favour of `into` from the trait `Into`." + )] + /// Freezes this buffer and return an immutable version of it. + /// + /// This method is only available under the default [`Global`](std::alloc::Global) + /// for now. Support for custom allocators will be added in a future release. + /// Related ticket: https://github.com/apache/arrow-rs/issues/3960 + pub fn freeze(self) -> Buffer { + self.into_buffer() + } + + /// Freezes this buffer and return an immutable version of it. + /// + /// This method is only available under the default [`Global`](std::alloc::Global) + /// for now. Support for custom allocators will be added in a future release. + /// Related ticket: https://github.com/apache/arrow-rs/issues/3960 + #[inline] + pub(super) fn into_buffer(self) -> Buffer { + let bytes = unsafe { Bytes::new(self.data, self.len, Deallocation::Standard(self.layout)) }; + std::mem::forget(self); + Buffer::from_bytes(bytes) + } } /// General methods @@ -393,22 +418,6 @@ impl MutableBuffer { self.data.as_ptr() } - #[deprecated( - since = "2.0.0", - note = "This method is deprecated in favour of `into` from the trait `Into`." - )] - /// Freezes this buffer and return an immutable version of it. - pub fn freeze(self) -> Buffer { - self.into_buffer() - } - - #[inline] - pub(super) fn into_buffer(self) -> Buffer { - let bytes = unsafe { Bytes::new(self.data, self.len, Deallocation::Standard(self.layout)) }; - std::mem::forget(self); - Buffer::from_bytes(bytes) - } - /// View this buffer as a mutable slice of a specific type. /// /// # Panics