pub fn match_expansion<EN: Fn(TokenStream, &FieldsNamed) -> (TokenStream, TokenStream), EU: Fn(TokenStream, &FieldsUnnamed) -> (TokenStream, TokenStream), U: Fn(TokenStream) -> TokenStream>(
derive_input: &DeriveInput,
expand_named: &EN,
expand_unnamed: &EU,
expand_unit: &U,
) -> TokenStream
Expand description
Handles the expansion of a struct/enum into a match statement that accesses every field for procedural code generation.
Requires several Fn helpers which perform expand different structures:
expand_named
handles the expansion of a struct or enum variant with named fields (e.g.struct Foo { bar: u32 }
,Foo::Bar { baz: u32 }
).expand_unnamed
handles the expansion of a struct or enum variant with unnamed fields (e.g.struct Foo(u32)
,Foo::Bar(u32)
).expand_unit
handles the expansion of a unit struct or enum (e.g.struct Foo;
,Foo::Bar
).
These helpers should themselves call generate_destructuring to generate the destructure necessary to access the fields of the value.