Contents

extracting(_:)

Extracts and returns a copy of the entire buffer.

Declaration

func extracting(_ bounds: (UnboundedRange_) -> ()) -> UnsafeMutableBufferPointer<Element>

Return Value

The same buffer as self.

Discussion

When Element is copyable, the extracting operation is equivalent to slicing the buffer then rebasing the resulting buffer slice:

let a = buffer
let b = buffer.extracting(...)
let c = UnsafeBufferPointer(rebasing: buffer[...])
// `a`, `b` and `c` are now all referring to the same buffer

Note that unlike slicing, the extracting operation remains available even if Element happens to be noncopyable.