I have to say @Alex want to check if T
type conforms to protocol rather than s
. And some answerer didn’t see clearly.
Check T
type conforms to protocol like this :
if let _ = T.self as? MyProtocol.Type {
// T conform MyProtocol
}
or
if T.self is MyProtocol.Type {
// T conform MyProtocol
}