Extension on Array where element is a generic struct in Swift

Viewed 1704

How would one extend an array of structs that have a generic type? Please see the below code for what I am trying to do.

struct MyStruct<T: MyProtocol> {
   ...
}

extension Array where Element: MyStruct<T> { // Not sure if T is supposed to be on this line.

    func doWork() -> [T] {
        ...
    }
}

Basically, how would I write the extension to have a method return an array of the generic type passed into the struct.

1 Answers
Related