advent_of_code_traits 0.2.0

Minimal, flexible framework for implementing solutions to Advent of Code in Rusts
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::env;
use std::fs;
use std::path::Path;

fn main() {
    let out_dir = env::var_os("OUT_DIR").unwrap();
    let dest_path = Path::new(&out_dir).join("const_days.rs");

    let code: String = (1..=25).map(|n| day(n)).collect::<Vec<_>>().join("\n");

    fs::write(&dest_path, &code).unwrap();
    println!("cargo:rerun-if-changed=build.rs");
}

fn day(n: u32) -> String {
    format!("pub const Day{0}: u32 = {0};", n)
}