Function pyo3_macros_backend::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 withfrom_py_with
- Derivation for structs with generic fields like
struct<T> Foo(T)
addsT: FromPyObject
on the derived implementation.