Skip to content

Annoying "where" clauses are required #1

Closed
@apt1002

Description

@apt1002

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions