(
&self,
py: Python,
target: &mut [T],
fort: u8,
)
| 453 | } |
| 454 | |
| 455 | fn copy_to_slice_impl<T: Element + Copy>( |
| 456 | &self, |
| 457 | py: Python, |
| 458 | target: &mut [T], |
| 459 | fort: u8, |
| 460 | ) -> PyResult<()> { |
| 461 | if mem::size_of_val(target) != self.len_bytes() { |
| 462 | return slice_length_error(py); |
| 463 | } |
| 464 | if !T::is_compatible_format(self.format()) || mem::size_of::<T>() != self.item_size() { |
| 465 | return incompatible_format_error(py); |
| 466 | } |
| 467 | unsafe { |
| 468 | err::error_on_minusone( |
| 469 | py, |
| 470 | ffi::PyBuffer_ToContiguous( |
| 471 | target.as_ptr() as *mut libc::c_void, |
| 472 | &*self.0 as *const ffi::Py_buffer as *mut ffi::Py_buffer, |
| 473 | self.0.len, |
| 474 | fort as libc::c_char, |
| 475 | ), |
| 476 | ) |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | /// Copies the buffer elements to a newly allocated vector. |
| 481 | /// If the buffer is multi-dimensional, the elements are written in C-style order. |
no test coverage detected