Skip to content

Commit 9b4e430

Browse files
committed
Clarify bulk-initialization contract
1 parent fc5b957 commit 9b4e430

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

proposals/nnnn-outputspan.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ extension OutputSpan where Element: ~Copyable {
116116

117117
##### Bulk initialization of an `OutputSpan`'s memory:
118118

119-
We include functions to perform bulk initialization of the memory represented by an `OutputSpan`. Initializing an `OutputSpan` from known-sized sources (such as `Collection` or `Span`) uses every element of the source. It is an error to do so when the available storage of the `OutputSpan` is too little to contain every element from the source. Initializing an `OutputSpan` from `Sequence` or `IteratorProtocol` will copy as many items as possible, either until the input is empty or the `OutputSpan`'s available storage is zero.
119+
We include functions to perform bulk initialization of the memory represented by an `OutputSpan`. Initializing an `OutputSpan` from a `Sequence` or a fixed-size source must use every element of the source. Initializing an `OutputSpan` from `IteratorProtocol` will copy as many items as possible, either until the input is empty or the `OutputSpan`'s available storage is zero.
120120

121121
```swift
122122
extension OutputSpan {
@@ -134,18 +134,24 @@ extension OutputSpan {
134134
) -> Bool
135135

136136
/// Initialize this span's suffix with every element of the source.
137+
///
138+
/// It is a precondition that the `OutputSpan` can contain every element of the source.
137139
@lifetime(self: copy self)
138140
public mutating func append(
139141
fromContentsOf source: some Sequence<Element>
140142
)
141143

142144
/// Initialize this span's suffix with every element of the source.
145+
///
146+
/// It is a precondition that the `OutputSpan` can contain every element of the source.
143147
@lifetime(self: copy self)
144148
public mutating func append(
145149
fromContentsOf source: Span<Element>
146150
)
147151

148152
/// Initialize this span's suffix with every element of the source.
153+
///
154+
/// It is a precondition that the `OutputSpan` can contain every element of the source.
149155
@lifetime(self: copy self)
150156
public mutating func append(
151157
fromContentsOf source: UnsafeBufferPointer<Element>
@@ -154,12 +160,16 @@ extension OutputSpan {
154160

155161
extension OutputSpan where Element: ~Copyable {
156162
/// Initialize this span's suffix by moving every element from the source.
163+
///
164+
/// It is a precondition that the `OutputSpan` can contain every element of the source.
157165
@lifetime(self: copy self)
158166
public mutating func moveAppend(
159167
fromContentsOf source: inout OutputSpan<Element>
160168
)
161169

162170
/// Initialize this span's suffix by moving every element from the source.
171+
///
172+
/// It is a precondition that the `OutputSpan` can contain every element of the source.
163173
@lifetime(self: copy self)
164174
public mutating func moveAppend(
165175
fromContentsOf source: UnsafeMutableBufferPointer<Element>
@@ -168,6 +178,8 @@ extension OutputSpan where Element: ~Copyable {
168178

169179
extension OutputSpan {
170180
/// Initialize this span's suffix by moving every element from the source.
181+
///
182+
/// It is a precondition that the `OutputSpan` can contain every element of the source.
171183
@lifetime(self: copy self)
172184
public mutating func moveAppend(
173185
fromContentsOf source: Slice<UnsafeMutableBufferPointer<Element>>

0 commit comments

Comments
 (0)