#Compiler claims I'm borrowing a struct
6 messages · Page 1 of 1 (latest)
but arent &x and x different from one another? why would this pose an issue?
If x == lowest_dist.1.0 and y == lowest_dist.1.1 then that Vertex will be mutated while also borrowed, which is not allowed.
For this I'd either copy Vertex from set so it's not borrowed, or if copying is expensive, use std::mem::take and then after the loop, use std::mem::replace to put it back. Assuming you never have the condition above, this should do the same thing but compile.
I've toyed around with copying but neither Vertex nor Set can implement it
What about Clone?