I have to following minimal example:
use std::iter::once;
trait TokenSpec {
type Ident;
}
impl TokenSpec for String {
type Ident = String;
}
struct Expr<I> {
ident: I,
}
type Input = Expr<<String as TokenSpec>::Ident>;
fn foo() -> impl Iterator<Item = Input> {
once(Expr { ident: "my_string".to_string() })
}
fn main() {
let v: Vec<_> = foo().collect();
println!("{:?}", v);
}
It fails to compile (playground) and I'm not sure why. The way I understand it, since String
is not a type parameter, its associated type should just be substituted with the concrete type for the resolution process.