[Solved] Issues with mut/non-mut borrowings


#1

I’m having some issues with mutable/non-mutable borrowings. I’ve been developing in Rust for almost a year now and I’ve never encountered such an interesting issue. The thing is, I have a struct where I want to push some string to an owned vector if something happens, depending on some information on that vector. I created the minimum example in Rust Playground:

https://is.gd/3Zdjxz

How can I fix it? It shouldn’t be so difficult, since I only need to push things, I won’t modify what it’s currently in the vector.


#2

Introducing an artificial scope helps: https://is.gd/7EhVVj (hope I didn’t change the meaning of code :slight_smile: )


#3

OMG, I had tried putting some artificial scopes but I didn’t manage to put them were they had do be. Thanks!!