protocol Factory
protocol Factory { init(_ f: () -> Self) } extension Factory { init(_ f: () -> Self) { self = f() } } extension Foo: Factory { } let foo = Foo { let a = 1 let b = "2" return Foo(a: a, b: b) }