MCPcopy Create free account
hub / github.com/PyO3/rust-numpy / acquire_mut

Function acquire_mut

src/borrow/shared.rs:188–199  ·  view source on GitHub ↗
(py: Python<'py>, array: *mut PyArrayObject)

Source from the content-addressed store, hash-verified

186}
187
188pub fn acquire_mut<'py>(py: Python<'py>, array: *mut PyArrayObject) -> Result<(), BorrowError> {
189 let shared = get_or_insert_shared(py).expect("Internal borrow checking API error");
190
191 let rc = unsafe { (shared.acquire_mut)(shared.flags, array) };
192
193 match rc {
194 0 => Ok(()),
195 -1 => Err(BorrowError::AlreadyBorrowed),
196 -2 => Err(BorrowError::NotWriteable),
197 rc => panic!("Unexpected return code {rc} from borrow checking API"),
198 }
199}
200
201pub fn release<'py>(py: Python<'py>, array: *mut PyArrayObject) {
202 let shared = get_or_insert_shared(py).expect("Internal borrow checking API error");

Callers 2

try_newMethod · 0.85
resizeMethod · 0.85

Calls 1

get_or_insert_sharedFunction · 0.85

Tested by

no test coverage detected