Given
protocol P {
typealias T
func foo(t: T) // e.g.
}I can do:
struct Baz<Y> {
let action: (Y) -> Void
}
extension P {
func bar(t: T) -> (baz: Baz<T>) -> Void {
return { baz in baz.action(t) }
}
}Is it possible to restrict T to being any protocol (AnyProtocol?) so that I can say
extension P {
func bar<U where U: T, U: AnyObject>(u: U) -> (baz: Baz<T>) -> Void {
return { [unowned u = u] baz in baz.action(u) }
}
}