Skip to content

class structs cannot contain class struct properties #182

@ju1ius

Description

@ju1ius

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,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds investigationSomething is wrong, we are just not sure what/why

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions