Macro darling::uses_type_params

source ·
macro_rules! uses_type_params {
    ($impl_type:ty, $accessor:ident) => { ... };
    ($impl_type:ty, $first:ident, $($field:ident),+) => { ... };
}
Expand description

Generator for UsesTypeParam impls that unions the used type parameters of the selected fields.

§Usage

The macro takes the type implementing the trait as the first argument, then a comma-separated list of fields for the rest of its arguments.

The type of each passed-in field must implement UsesTypeParams, or the resulting code won’t compile.

struct MyField {
    ty: syn::Type,
}

uses_type_params!(MyField, ty);

fn main() {
    // no test run
}

darling cannot derive this trait automatically, as it doesn’t know which information extracted from proc-macro input is meant to constitute “using” the type parameter, but crate consumers should implement it by hand or using the macro.