Closed
Description
The following code:
#![feature(nll)]
struct Foo<'a>(&'a [u8]);
impl<'a> Foo<'a> {
fn make_it(&self) -> impl Iterator<Item = u8> {
self.0.iter().copied()
}
}
gives the following error:
error: lifetime may not live long enough
--> src/lib.rs:6:26
|
5 | impl<'a> Foo<'a> {
| -- lifetime `'a` defined here
6 | fn make_it(&self) -> impl Iterator<Item = u8> {
| ^^^^^^^^^^^^^^^^^^^^^^^^ opaque type requires that `'a` must outlive `'static`
|
= help: consider replacing `'a` with `'static`
Suggsting that the user change the impl to impl Foo<'static>
is usually the wrong thing to do - it's more likely that the user wants to write impl Iterator<Item = u8> + 'a