Found 1 bookmarks
Custom sorting
Protocols III: Existential Spelling
Protocols III: Existential Spelling
Existentials and universals are [logical] “duals,” which means that one can be transformed into the other without losing its structure. So `AnySequence` is a universal type (generic) that’s equivalent to an explicit existential of `Sequence` (protocol). That’s why when you run into problems with protocols, your solution may be to convert it into generic structs (or vice versa). They solve the same problems in different ways with different trade-offs. And when you see “can only be used as a generic constraint,” what the compiler is really telling you is that protocols with associated types (PATs) don’t have an existential.
·robnapier.net·
Protocols III: Existential Spelling