Macro frame_support_procedural::match_and_insert

source ·
match_and_insert!() { /* proc-macro */ }
Expand description

Macro that inserts some tokens after the first match of some pattern.

§Example:

match_and_insert!(
    target = [{ Some content with { at some point match pattern } other match pattern are ignored }]
    pattern = [{ match pattern }] // the match pattern cannot contain any group: `[]`, `()`, `{}`
								  // can relax this constraint, but will require modifying the match logic in code
    tokens = [{ expansion tokens }] // content inside braces can be anything including groups
);

will generate:

    Some content with { at some point match pattern expansion tokens } other match patterns are
    ignored