I made a pyo3 "wrapper" for the rust version of the python module I've ended up maintaining. (See rust_pi3d and the pyo3_module) I got this to work quite well, however there was no way I could see pyo3 being rolled out while it depended on nightly Rust. Now, however it doesn't, so I thought I would revisit the project and get it to compile with stable Rust.
I had to make a few changes because of things that had disappeared or been added to pyo3 but now I'm down to one compiler error which is:
error[E0277]: the trait bound `std::vec::Vec<&core::Texture>: pyo3::FromPyObject<'_>` is not satisfied
--> src/shapes.rs:23:1
|
23 | #[pymethods]
| ^^^^^^^^^^^^ the trait `pyo3::FromPyObject<'_>` is not implemented for `std::vec::Vec<&core::Texture>`
|
= help: the following implementations were found:
<std::vec::Vec<T> as pyo3::FromPyObject<'a>>
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
This happens several times where I have a class method that takes a list of one of my defined pyo3 classes as an argument. i.e. for the above error Texture is defined
#[pyclass]
//#[derive(FromPyObject)] // gives error: cannot find derive macro `FromPyObject` in this scope
pub struct Texture {
pub r_texture: pi3d::texture::Texture,
}
(I tried to derive FromPyObject for Texture but the compiler didn't like that (use pyo3::prelude::* at the top)) The code generating the error above is
#[pymethods]
impl Shape {
...
fn set_textures(&mut self, textures: Vec<&::core::Texture>) {
let texlist = textures.iter().map(|t| t.r_texture.id).collect();
self.r_shape.set_textures(&texlist);
}
...
I've had a couple of goes at impl FromPyObject for Texture
but all seem to generate a lot more errors. Other method arguments such as Vec<f32>
don't seem to cause a problem. Is there something obvious I'm missing here?