Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Error code E0719

An associated item was specified more than once in a trait object.

Erroneous code example:

#![allow(unused)]
fn main() {
trait FooTrait {}
trait BarTrait {}

// error: associated type `Item` in trait `Iterator` is specified twice
type Foo = dyn Iterator<Item = u32, Item = u32>;
}

To fix this, remove the duplicate specifier:

Corrected example:

#![allow(unused)]
fn main() {
type Foo = dyn Iterator<Item = u32>; // ok!
}

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