Error code E0719

An associated type value was specified more than once.

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 }
Run

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 } // ok!
Run

For more information about associated types, see the book. For more information on associated type bounds, see RFC 2289.

Back to list of error codes