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

Method copy_to_slice

src/buffer.rs:434–436  ·  view source on GitHub ↗

Copies the buffer elements to the specified slice. If the buffer is multi-dimensional, the elements are written in C-style order. 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, you can use ` ::is_compatible_format

(&self, py: Python, target: &mut [T])

Source from the content-addressed store, hash-verified

432 /// you can use `<T as buffer::Element>::is_compatible_format(buf.format())`.
433 /// Alternatively, `match buffer::ElementType::from_format(buf.format())`.
434 pub fn copy_to_slice<T: Element + Copy>(&self, py: Python, target: &mut [T]) -> PyResult<()> {
435 self.copy_to_slice_impl(py, target, b'C')
436 }
437
438 /// Copies the buffer elements to the specified slice.
439 /// If the buffer is multi-dimensional, the elements are written in Fortran-style order.

Callers 1

test_bytes_bufferFunction · 0.80

Calls 1

copy_to_slice_implMethod · 0.80

Tested by 1

test_bytes_bufferFunction · 0.64