MCPcopy Create free account
hub / github.com/apache/arrow-rs / into_mutable

Method into_mutable

arrow-buffer/src/buffer/immutable.rs:383–397  ·  view source on GitHub ↗

Returns `MutableBuffer` for mutating the buffer if this buffer is not shared. Returns `Err` if this is shared or its allocation is from an external source or it is not allocated with alignment [`ALIGNMENT`] # Example: Creating a [`MutableBuffer`] from a [`Buffer`] ``` # use arrow_buffer::buffer::{Buffer, MutableBuffer}; let buffer: Buffer = Buffer::from(&[1u8, 2, 3, 4][..]); // Only possible to c

(self)

Source from the content-addressed store, hash-verified

381 ///
382 /// [`ALIGNMENT`]: crate::alloc::ALIGNMENT
383 pub fn into_mutable(self) -> Result<MutableBuffer, Self> {
384 let ptr = self.ptr;
385 let length = self.length;
386 Arc::try_unwrap(self.data)
387 .and_then(|bytes| {
388 // The pointer of underlying buffer should not be offset.
389 assert_eq!(ptr, bytes.ptr().as_ptr());
390 MutableBuffer::from_bytes(bytes).map_err(Arc::new)
391 })
392 .map_err(|bytes| Buffer {
393 data: bytes,
394 ptr,
395 length,
396 })
397 }
398
399 /// Converts self into a `Vec`, if possible.
400 ///

Callers 6

bitwise_bin_op_assignMethod · 0.80
test_vec_interopFunction · 0.80
into_builderMethod · 0.80
into_builderMethod · 0.80

Calls 1

and_thenMethod · 0.80

Tested by 1

test_vec_interopFunction · 0.64