duplicate!() { /* proc-macro */ }
Expand description

Duplicates the given code and substitutes specific identifiers for different code snippets in each duplicate.

This is a function-like procedural macro version of duplicate_item. It’s functionality is the exact same, and they share the same invocation syntax(es). The only difference is that duplicate doesn’t only duplicate the following item, but duplicate all code given to it after the invocation block.

§Usage

A call to duplicate must start with a [] containing the duplication invocation. Everything after that will then be duplicated according to the invocation.

Given the following duplicate call:

use duplicate::duplicate;

duplicate!{
  [
    // Some duplication invocation
  ]
  // Some code to duplicate
}

It is equivalent to the following invocation using duplicate_item:

use duplicate::duplicate_item;

#[duplicate_item(
  // Some duplication invocation
)]
// Some code to duplicate

For more details on about invocations and features see duplicate_item.