I used a separate vector when I first solved it, but wanted to try out this solution as well.
Using indices worked, thank you!
I used a separate vector when I first solved it, but wanted to try out this solution as well.
Using indices worked, thank you!
OK, so I’m thinking…
The error says I can’t combine immutable and mutable in the same function. I guess this makes sense, and that it’s because I’m not allowed to mutate an object while accessing it.
Is this a correct understanding of the error, or is there anything I can do to use this approach?
Thanks, I tried that. But now I get the error.
cannot borrow cards
as mutable because it is also borrowed as immutable
Thank you. I made the change suggested below to the linked one, but it still fails with the error.
cannot borrow cards
as mutable because it is also borrowed as immutable
No, that’s probably wrong.
I’ve just been trying different combinations of borrowing, but I can’t get it to works.
I’m pretty sure it’s the cards[id].copies += add
that is the cause of my issues.
Maybe I’m wrong, but using http could create a MITM vulnerability.
And for me this issue is my browser is setup to block http URLs. It’s just not a good look.
Hmmm, hosting a hacker post without an https url… 🤨
I solved it by using indicies instead, that way I got around the borrow checker.