exchange(_:with:)
Replaces the value of a mutable value with the supplied new value, returning the original.
Declaration
func exchange<T>(_ item: inout T, with newValue: consuming T) -> T where T : ~CopyableParameters
- item:
A mutable binding.
- newValue:
The new value of
item.
Return Value
The original value of item.
See Also
Memory Access
withUnsafePointer(to:_:)withUnsafePointer(to:_:)withUnsafeMutablePointer(to:_:)withUnsafeBytes(of:_:)withUnsafeMutableBytes(of:_:)withTemporaryAllocation(byteCount:alignment:_:)withTemporaryAllocation(of:capacity:_:)withUnsafeTemporaryAllocation(of:capacity:_:)withUnsafeTemporaryAllocation(byteCount:alignment:_:)swap(_:_:)