Skip to content

Commit 35d81b6

Browse files
committed
Clarify some requirements
1 parent 61fae31 commit 35d81b6

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

proposals/nnnn-outputspan.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ The converse operation `removeLast()` is also supported, and returns the removed
108108
```swift
109109
extension OutputSpan where Element: ~Copyable {
110110
/// Remove the last initialized element from this `OutputSpan`.
111+
///
112+
/// Returns the last element. The `OutputSpan` must not be empty
111113
@discardableResult
112114
@lifetime(self: copy self)
113-
public mutating func removeLast() -> Element?
115+
public mutating func removeLast() -> Element
114116
}
115117
```
116118

@@ -135,23 +137,26 @@ extension OutputSpan {
135137

136138
/// Initialize this span's suffix with every element of the source.
137139
///
138-
/// It is a precondition that the `OutputSpan` can contain every element of the source.
140+
/// It is a precondition that the `OutputSpan`'s uninitialized suffix
141+
/// can contain every element of the source.
139142
@lifetime(self: copy self)
140143
public mutating func append(
141144
fromContentsOf source: some Sequence<Element>
142145
)
143146

144147
/// Initialize this span's suffix with every element of the source.
145148
///
146-
/// It is a precondition that the `OutputSpan` can contain every element of the source.
149+
/// It is a precondition that the `OutputSpan`'s uninitialized suffix
150+
/// can contain every element of the source.
147151
@lifetime(self: copy self)
148152
public mutating func append(
149153
fromContentsOf source: Span<Element>
150154
)
151155

152156
/// Initialize this span's suffix with every element of the source.
153157
///
154-
/// It is a precondition that the `OutputSpan` can contain every element of the source.
158+
/// It is a precondition that the `OutputSpan`'s uninitialized suffix
159+
/// can contain every element of the source.
155160
@lifetime(self: copy self)
156161
public mutating func append(
157162
fromContentsOf source: UnsafeBufferPointer<Element>
@@ -161,15 +166,17 @@ extension OutputSpan {
161166
extension OutputSpan where Element: ~Copyable {
162167
/// Initialize this span's suffix by moving every element from the source.
163168
///
164-
/// It is a precondition that the `OutputSpan` can contain every element of the source.
169+
/// It is a precondition that the `OutputSpan`'s uninitialized suffix
170+
/// can contain every element of the source.
165171
@lifetime(self: copy self)
166172
public mutating func moveAppend(
167173
fromContentsOf source: inout OutputSpan<Element>
168174
)
169175

170176
/// Initialize this span's suffix by moving every element from the source.
171177
///
172-
/// It is a precondition that the `OutputSpan` can contain every element of the source.
178+
/// It is a precondition that the `OutputSpan`'s uninitialized suffix
179+
/// can contain every element of the source.
173180
@lifetime(self: copy self)
174181
public mutating func moveAppend(
175182
fromContentsOf source: UnsafeMutableBufferPointer<Element>
@@ -179,7 +186,8 @@ extension OutputSpan where Element: ~Copyable {
179186
extension OutputSpan {
180187
/// Initialize this span's suffix by moving every element from the source.
181188
///
182-
/// It is a precondition that the `OutputSpan` can contain every element of the source.
189+
/// It is a precondition that the `OutputSpan`'s uninitialized suffix
190+
/// can contain every element of the source.
183191
@lifetime(self: copy self)
184192
public mutating func moveAppend(
185193
fromContentsOf source: Slice<UnsafeMutableBufferPointer<Element>>
@@ -192,6 +200,8 @@ Bulk operations to deinitialize some or all of an `OutputSpan`'s memory is also
192200
extension OutputSpan where Element: ~Copyable {
193201
/// Remove the last N elements, returning the memory they occupy
194202
/// to the uninitialized state.
203+
///
204+
/// `n` must not be greater than `count`
195205
@lifetime(self: copy self)
196206
public mutating func removeLast(_ n: Int)
197207

0 commit comments

Comments
 (0)