From e7ed58d1a8283319bad20563ea8fd45ea47b29af Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Mon, 13 Nov 2023 12:14:53 -0500 Subject: [PATCH] Use std::ptr::replace --- arrow/src/pyarrow.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arrow/src/pyarrow.rs b/arrow/src/pyarrow.rs index 61b09769ac9..305bd0e470d 100644 --- a/arrow/src/pyarrow.rs +++ b/arrow/src/pyarrow.rs @@ -263,10 +263,12 @@ impl FromPyArrow for ArrayData { validate_pycapsule(array_capsule, "arrow_array")?; let schema_ptr = unsafe { schema_capsule.reference::() }; - let array_ptr = array_capsule.pointer() as *mut FFI_ArrowArray; - let array_mut = unsafe { array_ptr.as_mut() }; - - let array = std::mem::replace(array_mut.unwrap(), FFI_ArrowArray::empty()); + let array = unsafe { + std::ptr::replace( + array_capsule.pointer() as *mut FFI_ArrowArray, + FFI_ArrowArray::empty(), + ) + }; return ffi::from_ffi(array, schema_ptr).map_err(to_py_err); }