[][src]Function pyo3_derive_backend::build_derive_from_pyobject

pub fn build_derive_from_pyobject(tokens: &DeriveInput) -> Result<TokenStream>

Derive FromPyObject for enums and structs.

  • Max 1 lifetime specifier, will be tied to FromPyObject's specifier
  • At least one field, in case of #[transparent], exactly one field
  • At least one variant for enums.
  • Fields of input structs and enums must implement FromPyObject
  • Derivation for structs with generic fields like struct<T> Foo(T) adds T: FromPyObject on the derived implementation.