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

Function acquire

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

Source from the content-addressed store, hash-verified

174// These entry points will be used to access the shared borrow checking API from this extension:
175
176pub fn acquire<'py>(py: Python<'py>, array: *mut PyArrayObject) -> Result<(), BorrowError> {
177 let shared = get_or_insert_shared(py).expect("Internal borrow checking API error");
178
179 let rc = unsafe { (shared.acquire)(shared.flags, array) };
180
181 match rc {
182 0 => Ok(()),
183 -1 => Err(BorrowError::AlreadyBorrowed),
184 rc => panic!("Unexpected return code {rc} from borrow checking API"),
185 }
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");

Callers 2

try_newMethod · 0.85
cloneMethod · 0.85

Calls 1

get_or_insert_sharedFunction · 0.85

Tested by

no test coverage detected