MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / copy_from_slice

Method copy_from_slice

src/buffer.rs:531–533  ·  view source on GitHub ↗

Copies the specified slice into the buffer. If the buffer is multi-dimensional, the elements in the slice are expected to be in C-style order. Fails if the buffer is read-only. Fails if the slice does not have the correct length (`buf.item_count()`). Fails if the buffer format is not compatible with type `T`. To check whether the buffer format is compatible before calling this method, use `<T as

(&self, py: Python, source: &[T])

Source from the content-addressed store, hash-verified

529 /// use `<T as buffer::Element>::is_compatible_format(buf.format())`.
530 /// Alternatively, `match buffer::ElementType::from_format(buf.format())`.
531 pub fn copy_from_slice<T: Element + Copy>(&self, py: Python, source: &[T]) -> PyResult<()> {
532 self.copy_from_slice_impl(py, source, b'C')
533 }
534
535 /// Copies the specified slice into the buffer.
536 /// If the buffer is multi-dimensional, the elements in the slice are expected to be in Fortran-style order.

Callers 1

test_array_bufferFunction · 0.80

Calls 1

copy_from_slice_implMethod · 0.80

Tested by 1

test_array_bufferFunction · 0.64