Swift documentation says that protocols are treated like any other types, but looking at some examples, I see that 'type constraint' construct is being used instead of protocol.
Let's take the Swift dictionary for an example:
struct Dictionary<Key: Hashable, Value>: CollectionType, DictionaryLiteralConvertible {
// ...
subscript (key: Key) -> Value?
// ...
}
Couldn't that have been written like this
struct Dictionary<Value>: CollectionType, DictionaryLiteralConvertible {
// ...
subscript (key: Hashable) -> Value?
// ...
}
?
I can see type constraint useful with where conditions for types with associated types, but I'm not sure about this specific example.