Advanced Rust
Q61 / 100

What is the difference between associated types and generic type parameters in traits?

Correct! Well done.

Incorrect.

The correct answer is B) Associated types (type Output) bind one type per implementation (cleaner API); generics (T) allow multiple implementations per type for different T

B

Correct Answer

Associated types (type Output) bind one type per implementation (cleaner API); generics (T) allow multiple implementations per type for different T

Explanation

Iterator has type Item (one per impl). If it were generic Iterator<Item>, you could implement multiple Iterators for the same type with different items.

Progress
61/100