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: proposals/nnnn-MutableSpan.md
+13-13Lines changed: 13 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -96,10 +96,12 @@ This function returns an instance of `MutableSpan` that represents a mutation of
96
96
var array = [1, 2, 3, 4, 5]
97
97
var span1 = array.mutableSpan
98
98
var span2 = span1.extracting(3..<5)
99
-
// span1 cannot be accessed here
99
+
//neither array nor span1 can be accessed here
100
100
span2.swapAt(0, 1)
101
101
_=consume span2 // explicitly end scope for `span2`
102
-
print(array) // [1, 2, 3, 5, 4]
102
+
span1.swapAt(0, 1)
103
+
_=consume span1 // explicitly end scope for `span1`
104
+
print(array) // [2, 1, 3, 5, 4]
103
105
```
104
106
105
107
As established in [SE-0437][SE-0437], the instance returned by the `extracting()` function does not share indices with the function's callee.
@@ -169,7 +171,7 @@ for i in myMutableSpan.indices {
169
171
We include functions to perform bulk copies of elements into the memory represented by a `MutableSpan`. Updating a `MutableSpan` from known-sized sources (such as `Collection` or `Span`) copies every element of a source. It is an error to do so when there is the span is too short to contain every element from the source. Updating a `MutableSpan` from `Sequence` or `IteratorProtocol` instances will copy as many items as possible, either until the input is empty or until the operation has updated the item at the last index. The bulk operations return the index following the last element updated.
170
172
171
173
```swift
172
-
extensionMutableSpanwhereElement:Copyable{
174
+
extensionMutableSpanwhereElement:Copyable{
173
175
/// Updates every element of this span's to the given value.
174
176
mutatingfuncupdate(
175
177
repeatingrepeatedValue: Element
@@ -179,12 +181,12 @@ extension MutableSpan where Element: Copyable{
179
181
mutatingfuncupdate<S: Sequence>(
180
182
fromsource: S
181
183
) -> (unwritten: S.Iterator, index: Index) where S.Element==Element
182
-
184
+
183
185
/// Updates the span's elements with the elements from the source
184
186
mutatingfuncupdate(
185
187
fromsource: inoutsomeIteratorProtocol<Element>
186
188
) ->Index
187
-
189
+
188
190
/// Updates the span's elements with every element of the source.
189
191
mutatingfuncupdate(
190
192
fromContentsOfsource: someCollection<Element>
@@ -196,7 +198,7 @@ extension MutableSpan where Element: ~Copyable
196
198
mutating func update(
197
199
fromContentsOf source: Span<Element>
198
200
) -> Index
199
-
201
+
200
202
/// Updates the span's elements with every element of the source.
/// Returns a span over all but the given number of initial elements.
251
253
@_lifetime(inoutself)
@@ -292,8 +294,7 @@ extension MutableSpan where Element: ~Copyable {
292
294
}
293
295
```
294
296
295
-
296
-
##### Interoperability with unsafe code:
297
+
##### Interoperability with unsafe code
297
298
298
299
```swift
299
300
extensionMutableSpanwhereElement:~Copyable {
@@ -457,6 +458,7 @@ extension MutableRawSpan {
457
458
```
458
459
459
460
##### Extracting sub-spans
461
+
460
462
These functions extract sub-spans of the callee. The first two perform strict bounds-checking. The last four return prefixes or suffixes, where the number of elements in the returned sub-span is bounded by the number of elements in the parent `MutableRawSpan`.
461
463
462
464
```swift
@@ -513,8 +515,6 @@ extension MutableRawSpan {
513
515
}
514
516
```
515
517
516
-
517
-
518
518
##### Interoperability with unsafe code:
519
519
520
520
```swift
@@ -697,11 +697,11 @@ It is desirable to have a way to split a `MutableSpan` in multiple parts, for di
Unfortunately, tuples do not support non-copyable values yet. We may be able to use `InlineArray` ([SE-0453][SE-0453]), or a bespoke type, but destructuring the non-copyable constituent part remains a challenge. Solving this issue for `Span` and `MutableSpan` is a top priority.
704
+
Unfortunately, tuples do not support non-copyable or non-escapable values yet. We may be able to use `InlineArray` ([SE-0453][SE-0453]), or a bespoke type, but destructuring the non-copyable constituent part remains a challenge. Solving this issue for `Span` and `MutableSpan` is a top priority.
0 commit comments