Skip to content

Instantly share code, notes, and snippets.

@JadenGeller
Created January 18, 2022 03:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JadenGeller/628d49b5efb5f9f0256301465c118aab to your computer and use it in GitHub Desktop.
Save JadenGeller/628d49b5efb5f9f0256301465c118aab to your computer and use it in GitHub Desktop.
@resultBuilder
enum ResultBuilder<Expression> {
case block([Self])
static func buildBlock(_ components: Self...) -> Self {
.block(components)
}
case expression(Expression)
static func buildExpression(_ expression: Expression) -> Self {
.expression(expression)
}
indirect case optional(Self?)
static func buildOptional(_ component: Self?) -> Self {
.optional(component)
}
indirect case either(first: Self)
static func buildEither(first component: Self) -> Self {
.either(first: component)
}
indirect case either(second: Self)
static func buildEither(second component: Self) -> Self {
.either(second: component)
}
case array([Self])
static func buildArray(_ components: [Self]) -> Self {
.array(components)
}
indirect case limitedAvailability(Self)
static func buildLimitedAvailability(_ component: Self) -> Self {
.limitedAvailability(component)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment