All the methods on the traits so far are associated functions.
So essentially the implementing struct is just a marker or container for organising the solutions. It has no use for any data or fields.
I'd like people to experiment with this idea, I have in mind fun implementations of Solution like this:
// from Advent of Code 2019
pub struct IntcodeComputer {
program: Vec<Instruction>,
stack: Vec<i32>,
register: HashMap<Register, i32>,
}
impl Solution<Day2> for IntcodeComputer {
fn part1(&self) -> u32 {
// use the intcode computer and access its fields, methods!
self.program.iter() // ...
}
}
We could even have mutability.
impl Solution<Day2> for IntcodeComputer {
fn part1(&mut self) -> u32 {
// use the intcode computer and mutate it while solving the solution
self.stack.push(3)
}
}
All the methods on the traits so far are associated functions.
So essentially the implementing struct is just a marker or container for organising the solutions. It has no use for any data or fields.
I'd like people to experiment with this idea, I have in mind fun implementations of Solution like this:
We could even have mutability.