(
&self,
py: Python,
source: &[T],
fort: u8,
)
| 551 | } |
| 552 | |
| 553 | fn copy_from_slice_impl<T: Element + Copy>( |
| 554 | &self, |
| 555 | py: Python, |
| 556 | source: &[T], |
| 557 | fort: u8, |
| 558 | ) -> PyResult<()> { |
| 559 | if self.readonly() { |
| 560 | return buffer_readonly_error(py); |
| 561 | } |
| 562 | if mem::size_of_val(source) != self.len_bytes() { |
| 563 | return slice_length_error(py); |
| 564 | } |
| 565 | if !T::is_compatible_format(self.format()) || mem::size_of::<T>() != self.item_size() { |
| 566 | return incompatible_format_error(py); |
| 567 | } |
| 568 | unsafe { |
| 569 | err::error_on_minusone( |
| 570 | py, |
| 571 | ffi::PyBuffer_FromContiguous( |
| 572 | &*self.0 as *const ffi::Py_buffer as *mut ffi::Py_buffer, |
| 573 | source.as_ptr() as *mut libc::c_void, |
| 574 | self.0.len, |
| 575 | fort as libc::c_char, |
| 576 | ), |
| 577 | ) |
| 578 | } |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | fn slice_length_error(py: Python) -> PyResult<()> { |
no test coverage detected