fn foo<'a>(u: &'a usize) -> impl IntoIterator<Item = usize> + 'a {
std::thread::spawn(|| {
println!("{}", u);
});
vec![]
}
displays:
error: cannot infer an appropriate lifetime
--> src/lib.rs:2:24
|
2 | std::thread::spawn(|| {
| _____------------------_^
| | |
| | this return type evaluates to the `'static` lifetime...
3 | | println!("{}", u);
4 | | });
| |_____^ ...but this borrow...
|
note: ...can't outlive the lifetime 'a as defined on the function body at 1:8
Notice how `'static` is surrounded in backticks, but 'a is not.
displays:
Notice how
`'static`is surrounded in backticks, but'ais not.