Gets a pointer to the specified item. If `indices.len() < self.dimensions()`, returns the start address of the sub-array at the specified dimension.
(&self, indices: &[usize])
| 187 | /// |
| 188 | /// If `indices.len() < self.dimensions()`, returns the start address of the sub-array at the specified dimension. |
| 189 | pub fn get_ptr(&self, indices: &[usize]) -> *mut libc::c_void { |
| 190 | let shape = &self.shape()[..indices.len()]; |
| 191 | for i in 0..indices.len() { |
| 192 | assert!(indices[i] < shape[i]); |
| 193 | } |
| 194 | unsafe { |
| 195 | ffi::PyBuffer_GetPointer( |
| 196 | &*self.0 as *const ffi::Py_buffer as *mut ffi::Py_buffer, |
| 197 | indices.as_ptr() as *mut usize as *mut crate::Py_ssize_t, |
| 198 | ) |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | /// Gets whether the underlying buffer is read-only. |
| 203 | #[inline] |