pyo3_macros_backend::frompyobject

Function build_derive_from_pyobject

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

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 or be annotated with from_py_with
  • Derivation for structs with generic fields like struct<T> Foo(T) adds T: FromPyObject on the derived implementation.
⚠️ Internal Docs ⚠️ Not Public API 👉 Official Docs Here