Function generate_destructuring

Source
pub fn generate_destructuring<'a, I: Fn(&Field) -> bool>(
    fields: impl ExactSizeIterator<Item = &'a Field>,
    filter_field: &I,
) -> (TokenStream, Vec<TokenStream>)
Expand description

Generates a match arm destructuring pattern for the given fields.

If no filter_field function is provided, all fields are included in the pattern. If a filter_field function is provided, only fields for which the function returns true are included in the pattern. If any field is ignored, a wildcard pattern is added to the end of the pattern, making it non-exhaustive.

Returns both the capture pattern token stream and the name of the bound identifiers corresponding to the input fields.