tuple

Macro tuple 

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

This macro generates a tuple with repeated blocks of code.

§Arguments

  • n - The number of times to repeat the block.
  • ident - The identifier to use within the block.
  • block - The block of code to repeat.

§Example

use op_proc::tuple;
let arr = [4, 5, 6, 7, 8];
let ntuple = tuple!(3, i, {
   arr[i + 1] + 1
});
assert_eq!(ntuple, (6, 7, 8));

This will expand to:

(
    {
        let i = 0;
        arr[i + 1] + 1
    },
    {
        let i = 1;
        arr[i + 1] + 1
    },
    {
        let i = 2;
        arr[i + 1] + 1
    }
)