you can also leverage swift's switch case pattern matching, if you want to handle multiple cases of type T
:
func myFunc(s: MyStruct) -> T? {
switch s {
case let sType as MyProtocol:
// do MyProtocol specific stuff here, using sType
default:
//this does not conform to MyProtocol
...
}
}