Reputation: 1
This example is from rust's error-index, whose explanation I still can't understand why this is the case
#![allow(unused)]
fn main() {
pub trait Foo<T> {
type A;
fn get(&self, t: T) -> Self::A;
}
fn foo2<I: for<'x> Foo<&'x isize>>(field: I::A) {} // error!
}
Upvotes: 0
Views: 176
Reputation: 71595
I
does not implement Foo
once in foo2()
. It implements it multiple times, once for each lifetime of 'x
.
Because of that, there is also not a single value for <I as Foo>::A
. There are multiple, one for each instantiation of 'x
.
When you want to specify I::A
, you need to tell the compiler which I::A
- that is, which lifetime to bind 'x
with.
Upvotes: 2