-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Mutable references in field #15868
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
Comments
Not sure if this solves it, but fn get_mut(&'r mut self, i: uint) -> &'r mut int {
self.v.get_mut(i)
} compiles fine. Is the explicit lifetime on |
@prajwalkman, Yes, but for example if I want to implement mutable iterator |
Hm upon re-reflection I believe this is actually intended behavior. You cannot take out a mutable borrow longer than the lifetime of the mutable borrow which granted mutable access. In this case the function is trying to borrow |
fix: failed to infer OUT_DIR when workspace root contains symlink fix rust-lang#15867
Sorry, maybe it is hundred times solved problem, but I cannot use structure filed, which is mutable reference with longer lifetime, than the structure itself. In this code
in function
get_mut
I got an error,lifetime of 'self' is too short
. But without allmut
keywords code runs without errors.The text was updated successfully, but these errors were encountered: