This function makes it possible to use an out-of-place operation on some object where only in-place variants exist. simply use it as following
func outOfPlaceVariant(_ element: T) -> T {
outOfPlace(with: element) { $0.inPlaceVariant() }
}| func outOfPlace<T>(with element: T, _ f: (inout T) throws -> ()) rethrows -> T { | |
| try f(&element) | |
| return element | |
| } |