@@ -22,15 +22,31 @@ The actual work is being performed on the [swift-3-api-guidelines
22
22
branch] [ swift-3-api-guidelines-branch ] of the [ Swift repository] [ swift-repo ] .
23
23
On high level, the changes can be summarized as follows.
24
24
25
- * Strip ` Type ` suffix from remaining protocol names. In a few special cases
25
+ * Strip ` Type ` suffix from protocol names. In a few special cases
26
26
this means adding a ` Protocol ` suffix to get out of the way of type
27
27
names that are primary (though most of these we expect to be
28
28
obsoleted by Swift 3 language features).
29
29
30
- * The concept of ` generator ` is renamed to ` iterator ` .
30
+ * The concept of ` generator ` is renamed to ` iterator ` across all APIs .
31
31
32
32
* ` IndexingGenerator ` is renamed to ` DefaultCollectionIterator ` .
33
33
34
+ * The type ` Bit ` , which was only used as the index for ` CollectionOfOne ` , was
35
+ removed. We recommend using ` Int ` instead.
36
+
37
+ * The generic parameter name in unsafe pointer types was renamed from ` Memory `
38
+ to ` Pointee ` .
39
+
40
+ * No-argument initializers were removed from unsafe pointer types. We
41
+ recommend using the ` nil ` literal instead.
42
+
43
+ * ` PermutationGenerator ` was removed.
44
+
45
+ * ` MutableSliceable ` was removed. Use `CollectionType where SubSequence :
46
+ MutableCollectionType` instead.
47
+
48
+ * ` sort() ` => ` sorted() ` , ` sortInPlace() ` => ` sort() ` .
49
+
34
50
** More changes will be summarized here as they are implemented.**
35
51
36
52
## API diffs
@@ -39,6 +55,203 @@ Differences between Swift 2.2 Standard library API and the proposed API are
39
55
added to this section as they are being implemented on the
40
56
[ swift-3-api-guidelines branch] [ swift-3-api-guidelines-branch ] .
41
57
58
+ For repetitive changes that affect many types, only one representative instance
59
+ is shown in the diff. For example, ` generate() ` was renamed to ` iterator() ` .
60
+ We only show the diff for the protocol requirement, and all other renames of
61
+ this method are implied.
62
+
63
+ * Strip ` Type ` suffix from protocol names.
64
+
65
+ ``` swift
66
+ - public protocol CollectionType : ... { ... }
67
+ + public protocol Collection : ... { ... }
68
+
69
+ - public protocol MutableCollectionType : ... { ... }
70
+ + public protocol MutableCollection : ... { ... }
71
+
72
+ - protocol RangeReplaceableCollectionType : ... { ... }
73
+ + protocol RangeReplaceableCollection : ... { ... }
74
+ ```
75
+
76
+ * The concept of ` generator ` is renamed to ` iterator ` across all APIs.
77
+
78
+ ``` swift
79
+ public protocol Collection : ... {
80
+ - typealias Generator : GeneratorType = IndexingGenerator <Self >
81
+ + typealias Iterator : IteratorProtocol = DefaultCollectionIterator<Self >
82
+
83
+ - func generate () -> Generator
84
+ + func iterator () -> Iterator
85
+ }
86
+
87
+ - public struct IndexingGenerator <Elements : Indexable > : ... { ... }
88
+ + public struct DefaultCollectionIterator <Elements : Indexable > : ... { ... }
89
+ ```
90
+
91
+ * The type ` Bit ` , which was only used as the index for ` CollectionOfOne ` , was
92
+ removed. We recommend using ` Int ` instead.
93
+
94
+ ``` swift
95
+ - public enum Bit : ... { ... }
96
+ ```
97
+
98
+ * ` PermutationGenerator ` was removed.
99
+
100
+ ``` swift
101
+ - public struct PermutationGenerator <
102
+ - C : CollectionType , Indices : SequenceType
103
+ - where C.Index == Indices .Generator .Element
104
+ -> : ... { ... }
105
+ ```
106
+
107
+ * ` MutableSliceable ` was removed. Use `CollectionType where SubSequence :
108
+ MutableCollectionType` instead.
109
+
110
+ ``` swift
111
+ - public protocol MutableSliceable : CollectionType , MutableCollectionType {
112
+ - subscript (_ : Range <Index >) -> SubSequence { get set }
113
+ - }
114
+ ```
115
+
116
+ * The generic parameter name in unsafe pointer types was renamed from ` Memory `
117
+ to ` Pointee ` .
118
+
119
+ * No-argument initializers were removed from unsafe pointer types. We
120
+ recommend using the ` nil ` literal instead.
121
+
122
+ ``` swift
123
+ public struct AutoreleasingUnsafeMutablePointer <
124
+ - Memory
125
+ + Pointee
126
+ > ... : {
127
+
128
+ - public var memory: Memory
129
+ + public var pointee: Pointee
130
+
131
+ // Use `nil` instead.
132
+ - public init ()
133
+
134
+ }
135
+
136
+ - public func unsafeUnwrap <T >(nonEmpty : T? ) -> T
137
+ extension Optional {
138
+ + public var unsafelyUnwrapped: Wrapped { get }
139
+ }
140
+
141
+ - public struct COpaquePointer : ... {
142
+ + public struct OpaquePointer : ... {
143
+
144
+ // Use `nil` instead.
145
+ - public init ()
146
+
147
+ }
148
+
149
+ ```
150
+
151
+ * `sort ()` => `sorted ()`, `sortInPlace ()` => `sort ()`.
152
+
153
+ ```swift
154
+ extension Sequence where Self .Generator .Element : Comparable {
155
+ @warn_unused_result
156
+ - public func sort () -> [Generator .Element ]
157
+ + public func sorted () -> [Generator .Element ]
158
+ }
159
+
160
+ extension Sequence {
161
+ @warn_unused_result
162
+ - public func sort (
163
+ + public func sorted(
164
+ @noescape isOrderedBefore : (Generator .Element , Generator .Element ) -> Bool
165
+ ) -> [Generator .Element ]
166
+ }
167
+
168
+ extension MutableCollection where Self .Generator .Element : Comparable {
169
+ @warn_unused_result (mutable_variant= " sort" )
170
+ - public func sort () -> [Generator .Element ]
171
+ + public func sorted () -> [Generator .Element ]
172
+ }
173
+
174
+ extension MutableCollection {
175
+ @warn_unused_result (mutable_variant= " sort" )
176
+ - public func sort (
177
+ + public func sorted(
178
+ @noescape isOrderedBefore : (Generator .Element , Generator .Element ) -> Bool
179
+ ) -> [Generator .Element ]
180
+ }
181
+
182
+ extension MutableCollection
183
+ where
184
+ Self .Index : RandomAccessIndex ,
185
+ Self .Generator .Element : Comparable {
186
+
187
+ - public mutating func sortInPlace ()
188
+ + public mutating func sort ()
189
+
190
+ }
191
+
192
+ extension MutableCollection where Self .Index : RandomAccessIndex {
193
+ - public mutating func sortInPlace (
194
+ + public mutating func sort(
195
+ @noescape isOrderedBefore : (Generator .Element , Generator .Element ) -> Bool
196
+ )
197
+ }
198
+ ```
199
+
200
+ * Miscellaneous changes.
201
+
202
+ ```swift
203
+ - public struct EnumerateGenerator <Base : GeneratorType > : ... {
204
+ + public struct EnumeratedIterator <Base : IteratorProtocol > : ... {
205
+
206
+ - public typealias Element = (index: Int , element: Base .Element )
207
+ + public typealias Element = (offset: Int , element: Base .Element )
208
+
209
+ }
210
+
211
+ public struct Array <Element > : ... {
212
+ // Same changes were also applied to `ArraySlice` and `ContiguousArray`.
213
+
214
+ - public init (count : Int , repeatedValue : Element )
215
+ + public init (repeating : Element , count : Int )
216
+
217
+ }
218
+
219
+ public protocol Collection : ... {
220
+ - public func underestimateCount () -> Int
221
+ + public var underestimatedCount: Int
222
+
223
+ @warn_unused_result
224
+ public func split (
225
+ - maxSplit : Int = Int .max ,
226
+ + maxSplits : Int = Int .max ,
227
+ - allowEmptySlices : Bool = false ,
228
+ + omitEmptySubsequences : Bool = true ,
229
+ @noescape isSeparator : (Generator .Element ) throws -> Bool
230
+ ) rethrows -> [SubSequence ]
231
+ }
232
+
233
+ // Changes to this protocol affect `Array`, `ArraySlice`, `ContiguousArray` and
234
+ // other types.
235
+ protocol RangeReplaceableCollection : ... {
236
+
237
+ - public mutating func insert (newElement : Element , atIndex i : Int )
238
+ + public mutating func insert (newElement : Element , at i : Int )
239
+
240
+ - public mutating func removeAtIndex (index : Int ) -> Element
241
+ + public mutating func removeAt (index : Int ) -> Element
242
+
243
+ - public mutating func removeAll (keepCapacity keepCapacity : Bool = false )
244
+ + public mutating func removeAll (keepingCapacity keepingCapacity : Bool = false )
245
+
246
+ - public mutating func replaceRange <
247
+ + public mutating func replaceSubrange<
248
+ C : CollectionType where C.Generator .Element == _Buffer.Element
249
+ >(
250
+ subRange : Range <Int >, with newElements : C
251
+ )
252
+ }
253
+ ```
254
+
42
255
## Impact on existing code
43
256
44
257
The proposed changes are massively source- breaking for Swift code, and will
0 commit comments