Skip to content

Instantly share code, notes, and snippets.

@mwrites
Created March 6, 2018 07:42
Show Gist options
  • Save mwrites/b5de8a961148cd61252a2aa4d5a9df1f to your computer and use it in GitHub Desktop.
Save mwrites/b5de8a961148cd61252a2aa4d5a9df1f to your computer and use it in GitHub Desktop.
ModifyingObject
//https://github.com/apple/swift-evolution/blob/master/proposals/0176-enforce-exclusive-access-to-memory.md
func modifying<T>(_ value: inout T, _ function: (inout T) -> ()) {
function(&value)
}
modifying(&object.pair) { pair in swap(&pair.x, &pair.y) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment