Why this fires¶
A trait declares an associated type without a default, but an implementation
does not define it. The compiler cannot project Self::Item (or another
associated name) from that implementation.
trait Source {
type Item
}
struct Numbers {}
impl Source for Numbers {
// error[TE481]: missing associated type `Item`
}Fix it¶
Define the associated type in the impl:
impl Source for Numbers {
type Item = int
}An associated type with a trait-level default does not have to be repeated.