Skip to content

Commit 2f4c8b0

Browse files
committed
Add SE-0366 and 377 to the changelog.
1 parent afa76e2 commit 2f4c8b0

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

CHANGELOG.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,47 @@
22

33
_**Note:** This is in reverse chronological order, so newer entries are added to the top._
44

5+
## Swift 5.9
6+
7+
* [SE-0366][]:
8+
9+
The lifetime of a local variable value can be explicitly ended using the
10+
`consume` operator, forwarding ownership to the surrounding call, assignment,
11+
or initialization without copying:
12+
13+
```swift
14+
var x: [String] = []
15+
x.append("apples")
16+
x.append("bananas")
17+
x.append("oranges")
18+
19+
process(consume x) // forward the current value, without copying
20+
21+
x = [] // start building a new value
22+
x.append("broccoli")
23+
x.append("cauliflower")
24+
x.append("asparagus")
25+
...
26+
```
27+
28+
* [SE-0377][]:
29+
30+
Functions can now declare whether they take value parameters by `borrowing`
31+
access to a value provided by the caller, or by `consuming` a value that the
32+
callee is allowed to take ownership of:
33+
34+
```
35+
struct HealthyFoods {
36+
var values: [String] = []
37+
38+
// Ask to `consume` the parameter, since we want to use it
39+
// to incorporate into our own `values` array
40+
mutating func add(_ value: consuming String) {
41+
values.append(value)
42+
}
43+
}
44+
```
45+
546
## Swift 5.8
647

748
* [SE-0376][]:
@@ -9637,8 +9678,10 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
96379678
[SE-0358]: <https://github.com/apple/swift-evolution/blob/main/proposals/0358-primary-associated-types-in-stdlib.md>
96389679
[SE-0362]: <https://github.com/apple/swift-evolution/blob/main/proposals/0362-piecemeal-future-features.md>
96399680
[SE-0365]: <https://github.com/apple/swift-evolution/blob/main/proposals/0365-implicit-self-weak-capture.md>
9681+
[SE-0366]: <https://github.com/apple/swift-evolution/blob/main/proposals/0366-move-function.md>
96409682
[SE-0370]: <https://github.com/apple/swift-evolution/blob/main/proposals/0370-pointer-family-initialization-improvements.md>
96419683
[SE-0376]: <https://github.com/apple/swift-evolution/blob/main/proposals/0376-function-back-deployment.md>
9684+
[SE-0377]: <https://github.com/apple/swift-evolution/blob/main/proposals/0377-parameter-ownership-modifiers.md>
96429685

96439686
[#42697]: <https://github.com/apple/swift/issues/42697>
96449687
[#42728]: <https://github.com/apple/swift/issues/42728>

0 commit comments

Comments
 (0)