Associated Types Trouble
The classic example of associated types trouble certainly is the
following Swift error message:
This happens once your type conforms to a protocol which conforms to
Equatable:
protocol Bookmarkable: Equatable {
}
struct User {
var bookmarks: [Bookmarkable]
}
Here, the problem is that Equatable contains a method == which has
two paramters of type Self. Protocol Methods with Self parameters
automatically opt in to associated types.
Let's investigate several patterns that allow
you to work your way around the associated type requirement or that
show how such a type can be handled.
