Pb with auto-impl trait for struct when &struct impl IntoIterator

Phrased differently, type parameters like I must resolve to a single type, and types that differ by lifetime are distinct types.

Phrased differently, Rust has no "generic type constructors" where you could state something like

// Made up syntax/functionality
impl<I<'*>, U> ListValues for U
where
    for<'a> I<'a>: Iterator<Item = u32>,
    for<'a> &'a U: IntoIterator<Item = u32, IntoIter = I<'a>>,
    U: Range,

(Though you can sometimes emulate it with traits.)

Fortunately as you pointed out, that's not actually necessary in this case, since you can just not equate the associated type with a generic type parameter.

2 Likes