Moving out of a function both owned and borrowed entities properly?

Thanks. That's a good way to see it.

2 Likes

The fact that you can't do that is why my previous post said that you should hide the context behind methods on the struct that use it in only safe ways.

I see. Makes sense, but I am trying to internalize that.

You can think of it this way: To make the struct self-referential, you construct a value that the borrow-checker can't check, and which you have to be careful with. If you expose that unchecked value to the user, then you are in trouble because the user might not be careful with it.

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.