reference
reference copied to clipboard
Document lifetime elision rules for `impl trait` in return position
It looks like there is lifetime elision logic for impl trait in return position, but these rules are not documented in the reference iuc:
The following code type-checks, but does not type-check without the explicit placeholder lifetime + '_:
struct Foo(u32);
// does not type-check without the placeholder lifetime
fn example1(foo: &Foo) -> impl Iterator<Item = u32> + '_ {
(0..).map(|n: u32| {
n + foo.0
})
}
Are the rules the same as the lifetime elision rules for trait objects?