-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logic of borrowing in Rust #46741
Comments
Yup! And since it's not a bug, I'm going to give this a close. Or rather, the bug is already covered by those issues. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When trying to compile this code:
I got a problem
To correct the code, we must split expression into two line:
I think it would be very inconvenient if such instructions appear in many places.
I think the logic of Rust in above code is:
t
first as mutable (but do nothing), and wait theexpression
has done.t
is borrowing as mutable, we borrow it again (as immutable) and we can not borrow, because it has already borrowed as mutable.And I suggest changing logic to:
Then we can write code more clearly.
This is just my thoughts. If something is not right, please give me some explanation. Thank you.
The text was updated successfully, but these errors were encountered: