finalize(for:)
Consume the output span and return the number of initialized elements.
Declaration
consuming func finalize(for buffer: Slice<UnsafeMutableBufferPointer<Element>>) -> IntParameters
- buffer:
The buffer we expect the
OutputSpanto reference. This must be the same region of memory passed to theOutputSpaninitializer.
Return Value
The number of initialized elements in the same buffer, as tracked by the consumed OutputSpan instance.
Discussion
This method should be invoked in the scope where the OutputSpan was created, when it is time to commit the contents of the updated buffer back into the construct being initialized.
The context that created the output span is expected to remember what memory region the span is addressing. This consuming method expects to receive a copy of the same buffer pointer as a (loose) proof of ownership.