File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 5
5
6
6
## Swift 6.0
7
7
8
+ * [ SE-0432] [ ] :
9
+ Noncopyable enums can be pattern-matched with switches without consuming the
10
+ value you switch over:
11
+
12
+ ``` swift
13
+ enum Lunch : ~ Copyable {
14
+ case soup
15
+ case salad
16
+ case sandwich
17
+ }
18
+
19
+ func isSoup (_ lunch : borrowing Lunch) -> Bool {
20
+ switch lunch {
21
+ case .soup : true
22
+ default : false
23
+ }
24
+ }
25
+ ```
26
+
27
+
28
+ * [ SE-0429] [ ] :
29
+ The noncopyable fields of certain types can now be consumed individually:
30
+
31
+ ``` swift
32
+ struct Token : ~ Copyable {}
33
+
34
+ struct Authentication : ~ Copyable {
35
+ let id: Token
36
+ let name: String
37
+
38
+ mutating func exchange (_ new : consuming Token) -> Token {
39
+ let old = self .id // <- partial consumption of 'self'
40
+ self = .init (id : new, name : self .name )
41
+ return old
42
+ }
43
+ }
44
+ ```
45
+
8
46
* [ SE-0427] [ ] :
9
47
You can now suppress ` Copyable ` on protocols, generic parameters,
10
48
and existentials:
@@ -10287,6 +10325,8 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
10287
10325
[SE- 0413 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0413-typed-throws.md
10288
10326
[SE- 0422 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0422-caller-side-default-argument-macro-expression.md
10289
10327
[SE- 0427 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0427-noncopyable-generics.md
10328
+ [SE- 0429 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0429-partial-consumption.md
10329
+ [SE- 0432 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0432-noncopyable-switch.md
10290
10330
[#64927 ]: < https: // github.com/apple/swift/issues/64927>
10291
10331
[#42697 ]: < https: // github.com/apple/swift/issues/42697>
10292
10332
[#42728 ]: < https: // github.com/apple/swift/issues/42728>
You can’t perform that action at this time.
0 commit comments