Error code E0719
An associated type value was specified more than once.
Erroneous code example:
#![allow(unused)] #![feature(associated_type_bounds)] fn main() { 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:
#![allow(unused)] #![feature(associated_type_bounds)] fn main() { trait FooTrait {} trait BarTrait {} trait FooBarTrait: FooTrait + BarTrait {} struct Foo<T: Iterator<Item: FooBarTrait>> { f: T } // ok! }
For more information about associated types, see the book. For more information on associated type bounds, see RFC 2289.