@@ -115,7 +115,7 @@ public protocol SetAlgebra : Equatable, ExpressibleByArrayLiteral {
115
115
/// - Note: if this set and `other` contain elements that are equal but
116
116
/// distinguishable (e.g. via `===`), which of these elements is present
117
117
/// in the result is unspecified.
118
- func union( _ other: Self ) -> Self
118
+ __consuming func union( _ other: __owned Self) -> Self
119
119
120
120
/// Returns a new set with the elements that are common to both this set and
121
121
/// the given set.
@@ -137,7 +137,7 @@ public protocol SetAlgebra : Equatable, ExpressibleByArrayLiteral {
137
137
/// - Note: if this set and `other` contain elements that are equal but
138
138
/// distinguishable (e.g. via `===`), which of these elements is present
139
139
/// in the result is unspecified.
140
- func intersection( _ other: Self ) -> Self
140
+ __consuming func intersection( _ other: __owned Self) -> Self
141
141
142
142
/// Returns a new set with the elements that are either in this set or in the
143
143
/// given set, but not in both.
@@ -155,7 +155,12 @@ public protocol SetAlgebra : Equatable, ExpressibleByArrayLiteral {
155
155
///
156
156
/// - Parameter other: A set of the same type as the current set.
157
157
/// - Returns: A new set.
158
- func symmetricDifference( _ other: Self ) -> Self
158
+ __consuming func symmetricDifference( _ other: __owned Self) -> Self
159
+
160
+ // FIXME(move-only types): SetAlgebra.insert is not implementable by a
161
+ // set with move-only Element type, since it would be necessary to copy
162
+ // the argument in order to both store it inside the set and return it as
163
+ // the `memberAfterInsert`.
159
164
160
165
/// Inserts the given element in the set if it is not already present.
161
166
///
@@ -189,7 +194,7 @@ public protocol SetAlgebra : Equatable, ExpressibleByArrayLiteral {
189
194
/// other means.
190
195
@discardableResult
191
196
mutating func insert(
192
- _ newMember: Element
197
+ _ newMember: __owned Element
193
198
) -> ( inserted: Bool , memberAfterInsert: Element )
194
199
195
200
/// Removes the given element and any elements subsumed by the given element.
@@ -231,7 +236,7 @@ public protocol SetAlgebra : Equatable, ExpressibleByArrayLiteral {
231
236
/// `OptionSet` types, this method returns any intersection between the
232
237
/// set and `[newMember]`, or `nil` if the intersection is empty.
233
238
@discardableResult
234
- mutating func update( with newMember: Element ) -> Element ?
239
+ mutating func update( with newMember: __owned Element) -> Element ?
235
240
236
241
/// Adds the elements of the given set to the set.
237
242
///
@@ -253,7 +258,7 @@ public protocol SetAlgebra : Equatable, ExpressibleByArrayLiteral {
253
258
/// // Prints "[2, 4, 6, 7, 0, 1, 3]"
254
259
///
255
260
/// - Parameter other: A set of the same type as the current set.
256
- mutating func formUnion( _ other: Self )
261
+ mutating func formUnion( _ other: __owned Self)
257
262
258
263
/// Removes the elements of this set that aren't also in the given set.
259
264
///
@@ -268,7 +273,7 @@ public protocol SetAlgebra : Equatable, ExpressibleByArrayLiteral {
268
273
/// // Prints "["Bethany", "Eric"]"
269
274
///
270
275
/// - Parameter other: A set of the same type as the current set.
271
- mutating func formIntersection( _ other: Self )
276
+ mutating func formIntersection( _ other: __owned Self)
272
277
273
278
/// Removes the elements of the set that are also in the given set and adds
274
279
/// the members of the given set that are not already in the set.
@@ -286,7 +291,7 @@ public protocol SetAlgebra : Equatable, ExpressibleByArrayLiteral {
286
291
/// // Prints "["Diana", "Forlani", "Alicia"]"
287
292
///
288
293
/// - Parameter other: A set of the same type.
289
- mutating func formSymmetricDifference( _ other: Self )
294
+ mutating func formSymmetricDifference( _ other: __owned Self)
290
295
291
296
//===--- Requirements with default implementations ----------------------===//
292
297
/// Returns a new set containing the elements of this set that do not occur
@@ -303,7 +308,7 @@ public protocol SetAlgebra : Equatable, ExpressibleByArrayLiteral {
303
308
///
304
309
/// - Parameter other: A set of the same type as the current set.
305
310
/// - Returns: A new set.
306
- func subtracting( _ other: Self ) -> Self
311
+ __consuming func subtracting( _ other: Self ) -> Self
307
312
308
313
/// Returns a Boolean value that indicates whether the set is a subset of
309
314
/// another set.
@@ -365,7 +370,7 @@ public protocol SetAlgebra : Equatable, ExpressibleByArrayLiteral {
365
370
/// // Prints "[6, 0, 1, 3]"
366
371
///
367
372
/// - Parameter sequence: The elements to use as members of the new set.
368
- init < S : Sequence > ( _ sequence: S ) where S. Element == Element
373
+ init < S : Sequence > ( _ sequence: __owned S) where S. Element == Element
369
374
370
375
/// Removes the elements of the given set from this set.
371
376
///
0 commit comments