aocd

Attribute Macro aocd 

Source
#[aocd]
Expand description

Annotate your main function with #[aocd(year, day)].

This sets up your main function so that you can use the aocd::input! and aocd::submit! macros.

You can optionally provide a third argument, a file name. If you do, this is treated as a test-input, containing a smaller input that you want to test your code on before submitting. In this case, the aocd::input! macro will read the input from that file instead of fetching it from the website, and the aocd::submit! macro will just be a println alias.

§Example

use aocd::*;

#[aocd(2015, 1)]
fn main() {
   let part_1_answer = input!().lines().len();
   submit!(1, part_1_answer);
}
use aocd::prelude::*;  // Same as `use aocd::*;', but clippy allows it.

#[aocd(2015, 1, "test_input.txt")]
fn main() {
   let part_1_answer = input!().lines().len();  // Reads from test_input.txt
   submit!(1, part_1_answer);  // Just prints the answer, doesn't submit it.
}

§Panics

Panics (i.e. surfaces a compile error) if the arguments are not two integers in the expected ranges, or if the optional third argument is not a string literal containing a valid file name.