You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+12-13Lines changed: 12 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -112,7 +112,7 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
112
112
113
113
*[SE-0346][]:
114
114
115
-
Protocols can now declare a list of one or more primary associated types:
115
+
Protocols can now declare a list of one or more _primary associated types_, which enable writing same-type requirements on those associated types using angle bracket syntax:
116
116
117
117
```swift
118
118
protocolGraph<Vertex, Edge> {
@@ -121,31 +121,30 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
121
121
}
122
122
```
123
123
124
-
A protocol-constrained type like `Graph<Int>` can now be written anywhere that
125
-
expects the right-hand side of a protocol conformance requirement:
124
+
You can now write a protocol name followed by type arguments in angle brackets, like
125
+
`Graph<Int, String>`, anywhere that a protocol conformance requirement may appear:
126
126
127
127
```swift
128
-
funcshortestPath<V, E>(_: some Graph<V>, from: V, to: V) -> [E]
128
+
funcshortestPath<V, E>(_: some Graph<V, E>, from: V, to: V) -> [E]
129
129
130
-
extensionGraph<Int> {...}
130
+
extensionGraph<Int, String> {...}
131
131
132
-
funcbuild() ->some Graph<String> {}
132
+
funcbuild() ->some Graph<Int, String> {}
133
133
```
134
134
135
-
A protocol-constrained type is equivalent to a conformance requirement to the protocol
136
-
itself together with a same-type requirement constraining the primary associated type.
135
+
A protocol name followed by angle brackets is shorthand for a conformance requirement,
136
+
together with a same-type requirement for the protocol's primary associated types.
137
137
The first two examples above are equivalent to the following:
138
138
139
139
```swift
140
140
funcshortestPath<V, E, G>(_: G, from: V, to: V) -> [E]
0 commit comments