How to simplify struct mutating in Swift
Issue #354
In Construction, we have a build
method to apply closure to inout
struct.
We can explicitly define that with withValue
1 | func withValue<T>(_ value: T, closure: (inout T) -> Void) -> T { |
So we can modify Protobuf structs easily
1 | user.book = withValue(Book()) { |