Error code E0222
An attempt was made to constrain an associated type.
Erroneous code example:
ⓘ
In this example, BoxCar
has two supertraits: Vehicle
and Box
. Both of
these traits define an associated type Color
. BoxCar
inherits two types
with that name from both supertraits. Because of this, we need to use the
fully qualified path syntax to refer to the appropriate Color
associated
type, either <BoxCar as Vehicle>::Color
or <BoxCar as Box>::Color
, but this
syntax is not allowed to be used in a function signature.
In order to encode this kind of constraint, a where
clause and a new type
parameter are needed: