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
* [se0467] extract slicing from future directions
* [se0467] clean up element constraints
* [se0467] fix another typo
* [se0467] fix a typo and parameter name
Copy file name to clipboardExpand all lines: proposals/0467-MutableSpan.md
+7-29Lines changed: 7 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -84,7 +84,7 @@ This lifetime relationship will apply to all the safe `var mutableSpan: MutableS
84
84
An important category of use cases for `MutableSpan` and `MutableRawSpan` consists of bulk copying operations. Often times, such bulk operations do not necessarily start at the beginning of the span, thus having a method to select a sub-span is necessary. This means producing an instance derived from the callee instance. We adopt the nomenclature already introduced in [SE-0437][SE-0437], with a family of `extracting()` methods.
We store a `UnsafeMutableRawPointer` value internally in order to explicitly support reinterpreted views of memory as containing different types of `BitwiseCopyable` elements. Note that the the optionality of the pointer does not affect usage of `MutableSpan`, since accesses are bounds-checked and the pointer is only dereferenced when the `MutableSpan` isn't empty, when the pointer cannot be `nil`.
126
126
127
127
Initializers, required for library adoption, will be proposed alongside [lifetime annotations][PR-2305]; for details, see "[Initializers](#initializers)" in the [future directions](#Directions) section.
/// The number of initialized elements in this `MutableSpan`.
132
132
var count: Int { get }
133
133
@@ -172,7 +172,7 @@ We include functions to perform bulk copies of elements into the memory represen
172
172
173
173
```swift
174
174
extensionMutableSpanwhereElement:Copyable {
175
-
/// Updates every element of this span's to the given value.
175
+
/// Updates every element of this span to the given value.
176
176
mutatingfuncupdate(
177
177
repeatingrepeatedValue: Element
178
178
)
@@ -224,7 +224,7 @@ extension MutableSpan where Element: Copyable {
224
224
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 `MutableSpan`.
/// Returns a span over the items within the supplied range of
229
229
/// positions within this span.
230
230
@_lifetime(inoutself)
@@ -427,7 +427,7 @@ extension MutableRawSpan {
427
427
428
428
/// Updates the span's bytes with the bytes of the elements from the source
429
429
mutatingfuncupdate<Element: BitwiseCopyable>(
430
-
fromelements: inoutsomeIteratorProtocol<Element>
430
+
fromsource: inoutsomeIteratorProtocol<Element>
431
431
) ->Int
432
432
433
433
/// Updates the span's bytes with every byte of the source.
@@ -669,28 +669,6 @@ Note: The future directions stated in [SE-0447](https://github.com/swiftlang/swi
669
669
670
670
These annotations have been [pitched][PR-2305-pitch] and, after revision, are expected to be pitched again soon. `MutableSpan` initializers using lifetime annotations will be proposed alongside the annotations themselves.
671
671
672
-
#### Functions providing variants of `MutableRawSpan` to `MutableSpan`
673
-
674
-
`MutableSpan`s representing subsets of consecutive elements could be extracted out of a larger `MutableSpan` with an API similar to the `extracting()` functions recently added to `UnsafeBufferPointer` in support of non-copyable elements:
0 commit comments