Last active
February 24, 2024 05:10
-
-
Save joshuajhomann/86793a572337d272b1ad0d22f053e0dc to your computer and use it in GitHub Desktop.
With
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@discardableResult public func with<T>(_ item: T, update: (inout T) throws -> Void) rethrows -> T { | |
var copy = item | |
try update(©) | |
return copy | |
} | |
@inlinable | |
@discardableResult | |
public func with<T>( _ value: consuming T, update: (inout T) throws -> Void) rethrows -> T { | |
var copy = consume value | |
try update(©) | |
return copy | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment