Closed
Description
When writing something generic over <I: Index, J: Index>
it is true that (I, J): Index
but the type checker doesn't know that. The problem is actually with the Flatten
trait (a super-trait of Index
). The work-around is to add where clauses (I, J): Flatten, (I::Size, J::Size): Flatten
.
This is annoying. It seems to be a limitation of Rust, which might go away in future. We would like to write
trait Flattenable: for<F: Flat> Flatten<F> {}
impl<T: for<F: Flat> Flatten<F>> Flattenable for T {}
and then use Flattenable
instead of Flatten
as the super-trait of Index
. However, that's illegal.