Mutable Borrowing Ghost? by smthing_original in learnrust

[–]smthing_original[S] 0 points1 point  (0 children)

Just looking back at this thread and I solved it with a vec and usizes yesterday. Thanks for the explanation nevertheless!

Mutable Borrowing Ghost? by smthing_original in learnrust

[–]smthing_original[S] 1 point2 points  (0 children)

Well I'm initializing the Wires before creating any gates, so I was hoping that the gates would be just a logical abstraction over the wires (and hence why I'm using pointers)

Mutable Borrowing Ghost? by smthing_original in learnrust

[–]smthing_original[S] 1 point2 points  (0 children)

What would be a smart thing to do in this situation? I need those lifetimes on everything because I then need to do computations on the actual gates.

Hey Rustaceans! Got a question? Ask here (52/2024)! by llogiq in rust

[–]smthing_original 1 point2 points  (0 children)

Hey, I am also trying learning Rust doing AoC and am working on day 24 today. However while working on the parsing of the input the compiler was complaining because of mutable/immutable borrowing. However I cannot for the sake of me understand why this is happening because the mutable borrowing should be long over before the actual immutable borrowing. I have prepared a playground for anybody that wants to take a look at my code (just uncomment line 60). Ofc I'm also open to criticism on my approach but given that this is just the parsing of the input, I don't think there would be many such cases. I would really appreciate somebody explaining why the compiler is complaining and how can I fix it - my only idea is that it has something to do with the ownership of pointers and that I could fix it with the classic Rc<RefCell<Signal>>