Checklist
Problem
The documentation for result builders lists the following methods:
buildBlock(_ components: Component...) -> Component
buildOptional(_ component: Component?) -> Component
buildEither(first: Component) -> Component and buildEither(second: Component) -> Component
buildArray(_ components: [Component]) -> Component
buildExpression(_ expression: Expression) -> Component
buildFinalResult(_ component: Component) -> FinalResult
While RegistrationBuilder does technically satisfy these requirements, it does not reference Component or FinalResult directly. If the type aliases are changed, the functions will no longer match.
Feature Request
The static methods of RegistrationBuilder should be updated to reference Component and/or FinalResult as applicable, rather than [Registration]. Additionally, the last overload of buildExpression(_:) (where S.Element == Registration) should be changed to return .init(expression) or return Component(expression), rather than referencing Array explicitly.
In line with these changes, perhaps the method signature of Factory.register(builder:) should be updated as well, to register(@RegistrationBuilder builder: () -> RegistrationBuilder.FinalResult).
Value
This change would put RegistrationBuilder more closely in line with the documentation for result builders, and reduce the amount of work necessary in the future should the types be changed.
Checklist
Problem
The documentation for result builders lists the following methods:
buildBlock(_ components: Component...) -> ComponentbuildOptional(_ component: Component?) -> ComponentbuildEither(first: Component) -> ComponentandbuildEither(second: Component) -> ComponentbuildArray(_ components: [Component]) -> ComponentbuildExpression(_ expression: Expression) -> ComponentbuildFinalResult(_ component: Component) -> FinalResultWhile
RegistrationBuilderdoes technically satisfy these requirements, it does not referenceComponentorFinalResultdirectly. If the type aliases are changed, the functions will no longer match.Feature Request
The static methods of
RegistrationBuildershould be updated to referenceComponentand/orFinalResultas applicable, rather than[Registration]. Additionally, the last overload ofbuildExpression(_:)(where S.Element == Registration) should be changed toreturn .init(expression)orreturn Component(expression), rather than referencingArrayexplicitly.In line with these changes, perhaps the method signature of
Factory.register(builder:)should be updated as well, toregister(@RegistrationBuilder builder: () -> RegistrationBuilder.FinalResult).Value
This change would put
RegistrationBuildermore closely in line with the documentation for result builders, and reduce the amount of work necessary in the future should the types be changed.