| I wrote you a little example but i think you need to know rust to really understand it :( https://is.gd/FlBCJ0 you cannot uncomment the comments in the main function and use it wrong, the compiler prevents you to compile this code. these two sections from the book may help understad this https://doc.rust-lang.org/book/ownership.html https://doc.rust-lang.org/book/references-and-borrowing.html if you're more into videos this may help http://intorust.com/tutorial/ownership/ http://intorust.com/tutorial/shared-borrows/ |
As it stands, Rust code can break the principle of least surprise, since what happens in a method can affect the associated instance variable (in this case `open_socket`). A user could easily write several lines of code and only discover that `open_socket` has been moved into a method at compile-time.
I found myself having very small coding-compile iterations when writing in Rust to catch issues like this (but that was also undoubtedly due to the fact I was learning).
Is there a pro tip to avoid this issue?