ext-php-rs
ext-php-rs copied to clipboard
class structs cannot contain class struct properties
Hi, currently the following is not possible:
#[php_class]
struct Foo {
#[prop]
bar: Bar,
}
#[php_class]
#[derive(Clone)]
struct Bar {
#[prop]
value: String,
}
the trait bound `Bar: FromZval<'_>` is not satisfied
the trait `FromZval<'a>` is implemented for `&'a Bar`
required for `Bar` to implement `Prop<'_>`
required for the cast from `Bar` to the object type `dyn Prop<'_>` rustc(E0277)
This is supported in PyO3, from which this library seems to be inspired, so we should be able to do the same in ext_php_rs:
#[pyclass]
struct Foo {
#[pyo3(get)]
bar: Bar,
}
#[pyclass]
#[derive(Clone)]
struct Bar {
#[pyo3(get)]
value: String,
}