Closed
Description
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
struct A<'r> {
v: &'r mut Vec<int>
}
impl<'r> A<'r> {
fn create(v: &'r mut Vec<int>) -> A<'r> {
A::<'r> {
v: v
}
}
fn get_mut(&mut self, i: uint) -> &'r mut int {
self.v.get_mut(i)
}
}
in function get_mut
I got an error, lifetime of 'self' is too short
. But without all mut
keywords code runs without errors.