Let's say I have these protocols:
protocol SomeProtocol {
}
protocol SomeOtherProtocol {
}
Now, if I want a function that takes a generic type, but that type must conform to SomeProtocol
I could do:
func someFunc<T: SomeProtocol>(arg: T) {
// do stuff
}
But is there a way to add a type constraint for multiple protocols?
func bothFunc<T: SomeProtocol | SomeOtherProtocol>(arg: T) {
}
Similar things use commas, but in this case, it would start the declaration of a different type. Here's what I've tried.
<T: SomeProtocol | SomeOtherProtocol>
<T: SomeProtocol , SomeOtherProtocol>
<T: SomeProtocol : SomeOtherProtocol>