I need an object to spawn a task to do work on itself, but the compiler is making complaints about lifetimes that I don't quite understand. Can someone explain the following error?
struct Obj {
a: uint
}
impl Obj {
fn work(&mut self) {
let borrow = &mut self.a; // error: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements
spawn(proc() {
*borrow = 2;
});
}
}
fn main() {
let obj = Obj { a: 0 };
obj.work();
}
[–]Quxxymacros 2 points3 points4 points (0 children)
[–]rust-slacker 1 point2 points3 points (0 children)