MCPcopy Index your code
hub / github.com/PyO3/rust-numpy / IntoPyArray

Interface IntoPyArray

src/convert.rs:37–45  ·  view source on GitHub ↗

Conversion trait from owning Rust types into [`PyArray`]. This trait takes ownership of `self`, which means it holds a pointer into the Rust heap. In addition, some destructive methods like `resize` cannot be used with NumPy arrays constructed using this trait. # Example ``` use numpy::{PyArray, IntoPyArray, PyArrayMethods}; use pyo3::Python; Python::attach(|py| { let py_array = vec![1, 2, 3]

Source from the content-addressed store, hash-verified

35/// });
36/// ```
37pub trait IntoPyArray: Sized {
38 /// The element type of resulting array.
39 type Item: Element;
40 /// The dimension type of the resulting array.
41 type Dim: Dimension;
42
43 /// Consumes `self` and moves its data into a NumPy array.
44 fn into_pyarray<'py>(self, py: Python<'py>) -> Bound<'py, PyArray<Self::Item, Self::Dim>>;
45}
46
47impl<T: Element> IntoPyArray for Box<[T]> {
48 type Item = T;

Callers

nothing calls this directly

Implementers 1

convert.rssrc/convert.rs

Calls

no outgoing calls

Tested by

no test coverage detected