I have a class that takes a generic class Collection:
(Model
is a class) and a protocol (Resource
) that some of the s
The problem is Collection
is a generic class so every where you declare it, you must attached the specialized type, like Collection<T>
. However extension to a protocol can't be specified with a generic type so you end up not being able to supply T
to Collection
.
In your case though, T
is constrained to be of type Model
so why not use that in the default protocol implementation:
extension Resource where Self: Collection<Model> {
func fetch() {
// default implementation
}
}