Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The solving functions cannot receive a mutable reference #67

Open
NilsIrl opened this issue Dec 8, 2020 · 2 comments
Open

The solving functions cannot receive a mutable reference #67

NilsIrl opened this issue Dec 8, 2020 · 2 comments

Comments

@NilsIrl
Copy link

NilsIrl commented Dec 8, 2020

#[aoc(day8, part2)]
fn part2(input: &mut Vec<(Operation, i64)>) -> i64 {
error[E0308]: mismatched types
  --> src/day8.rs:46:1
   |
46 | #[aoc(day8, part2)]
   | ^^^^^^^^^^^^^^^^^^^ types differ in mutability
   |
   = note: expected mutable reference `&mut Vec<(day8::Operation, i64)>`
                      found reference `&_`
   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
@dantho
Copy link

dantho commented Dec 11, 2020

Yeah. That gets me, too. Maybe the tool considers that you may use the generated input twice, for each of Part1 and Part2.
That does happen a lot. Wouldn't want to regenerate in that case. Just guessing.

Workaround: let input = input.clone();

@NilsIrl
Copy link
Author

NilsIrl commented Dec 11, 2020

Maybe the tool considers that you may use the generated input twice, for each of Part1 and Part2.

I didn't think about that. Considering this, I'm tempted to close this issue because the solution would be for cargo-aoc to clone the input before passing it on to the solver, which I don't find ideal. However, for the benchmarks, I don't think people want the cloning of their input being taken into account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants