Document default types for associated values
| Previous ID | SR-8761 |
| Radar | None |
| Original Reporter | @natecook1000 |
| Type | Improvement |
Additional Detail from JIRA
| Votes | 0 |
| Component/s | |
| Labels | Improvement |
| Assignee | None |
| Priority | Medium |
md5: 5483446fdf4d37083296d04e708f33f2
Issue Description:
We don't appear to document the way you can provide a default type in an associate's type declaration. Noted in https://forums.swift.org/t/a-question-about-associatedtype-in-protocols/16168
This is used quite a fair bit in the standard library for doing things like providing a default implementation of a Collection's Slice type
associatedtype SubSequence : Collection = Slice<Self> where Self.Element == Self.SubSequence.Element, Self.SubSequence == Self.SubSequence.SubSequence
It seems strange that a really useful and used (at least in std lib) isn't documented at all in the Swift book
Now that TSPL is open source, I've opened https://github.com/apple/swift-book/issues/40 to track this issue.