# pyo3_macros_backend::build_derive_from_pyobject - Rust
Derive FromPyObject for enums and structs.
Keywords: rust, rustlang, rust-lang, build_derive_from_pyobject

# Function pyo3_macros_backend::build_derive_from_pyobject [−] [src]

    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.