The value for an associated type has already been specified.
Erroneous code example:
#![feature(associated_type_bounds)] trait FooTrait {} trait BarTrait {} // error: associated type `Item` in trait `Iterator` is specified twice struct Foo<T: Iterator<Item: FooTrait, Item: BarTrait>> { f: T }
Item
in trait Iterator
cannot be specified multiple times for struct Foo
. To fix this, create a new trait that is a combination of the desired traits and specify the associated type with the new trait.
Corrected example:
#![feature(associated_type_bounds)] trait FooTrait {} trait BarTrait {} trait FooBarTrait: FooTrait + BarTrait {} struct Foo<T: Iterator<Item: FooBarTrait>> { f: T }
For more information about associated types, see the book. For more information on associated type bounds, see RFC 2289.