example

Macro example 

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

Defines examples given in advent of code puzzles. The strings in the example are unindented using indoc.

There are three cases that make up 90% of examples in advent of code, which this macro addresses. Namely:

  • One example is given for both part 1 and part 2:
elvish::example!("
    YOUR
    EXAMPLE
    HERE
");
  • Part 1 and part 2 have each one example:
elvish::example!(
    part1: "
        YOUR
        PART 1
        EXAMPLE
        HERE
    ",

    part2: "
        YOUR
        PART 2
        EXAMPLE
        HERE
    ",
);
  • Part 1 and part 2 have more than one example:
elvish::example!(
    part1: "
        YOUR
        FIRST PART 1
        EXAMPLE
        HERE
    ",

    part1: "
        YOUR
        SECOND PART 1
        EXAMPLE
        HERE
    ",

    part2: "
        YOUR
        FIRST PART 2
        EXAMPLE
        HERE
    ",

    part2: "
        YOUR
        SECOND PART 2
        EXAMPLE
        HERE
    ",
);