Hi guys,
I guess the answer to this behaviour is extremely simple but I can't figure it out
Here my code:
use std::thread;
fn main() {
let test = TestThread{
value: 0
};
test.start();
}
struct TestThread {
value: i32
}
impl TestThread {
fn start(&self) {
let value = self.value;
thread::spawn(move || {
start_one(0); // this is ok
start_one(value); // this is ok
start_one(self.value); // this is not ok, why?!
});
}
}
pub fn start_one(value: i32) {}
The code does not compile with this error caused by the "start_one(self.value)" call:
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
I thought that "start_one(self.value)" would pass a copy of the integer value, so what is causing the lifetime issue?!?
I am especially baffled by the fact that the previous line (i.e. start_one(value); ) works at it seems to me that the two calls are technically identical.