Closure based configuration

Cool to see the form in the OP. It’s amazing how useful this pattern is. I use this:

precedencegroup ChainingPrecedence {
	associativity: left
	higherThan: AssignmentPrecedence
}

infix operator ~>: ChainingPrecedence
@inlinable @discardableResult public func ~> <T>(_ value: T, modifications: (inout T) throws -> Void) rethrows -> T {
	var value = value
	try modifications(&value)
	return value
}

let label = UILabel() ~> { $0.text = "text" }

let maybeValue: String? = nil
let error: [String:Any] = ["key" : maybeValue] // 'nil' is not compatible with expected dictionary value type 'Any'
let noError: [String:Any] = [:] ~> { $0["key"] = maybeValue }