Contents

withUnsafeMutableBufferPointer(_:)

Call a closure with a pointer to the viewed mutable contiguous storage.

Declaration

mutating func withUnsafeMutableBufferPointer<E, Result>(_ body: (UnsafeMutableBufferPointer<Element>) throws(E) -> Result) throws(E) -> Result where E : Error, Result : ~Copyable

Parameters

  • body:

    A closure with an UnsafeMutableBufferPointer parameter that points to the viewed contiguous storage. If body has a return value, that value is also used as the return value for the withUnsafeMutableBufferPointer(_:) method. The closure’s parameter is valid only for the duration of its execution.

Return Value

The return value of the body closure parameter.

Discussion

The buffer pointer passed as an argument to body is valid only during the execution of withUnsafeMutableBufferPointer(_:). Do not store or return the pointer for later use.