gobanos / cargo-aoc

447 stars 47 forks source link

Support cloned values #50

Open Proximyst opened 4 years ago

Proximyst commented 4 years ago

It'd be a great addition if we could generate values and have them cloned:

// This is day 2, 2019
#[aoc_generator(day2)]
pub fn gen(input: &str) -> Vec<isize> {
    input
        .split(",")
        .map(|s| s.trim())
        .flat_map(|s| s.parse::<isize>())
        .collect()
}

#[aoc(day2, part1)]
#[clone]
pub fn day2_impl1(input: Vec<isize>) -> isize {
    unimplemented!()
}
ThomasdenH commented 3 years ago

This should be timed in the benchmark as well, shouldn't it? If so, I'm not sure this is an improvement over just using let input = input.clone() on the first line.