Skip to content

Instantly share code, notes, and snippets.

@Sajjon
Last active August 17, 2020 12:54
Show Gist options
  • Save Sajjon/2d276b3bd85c5327bd3faf55536817a1 to your computer and use it in GitHub Desktop.
Save Sajjon/2d276b3bd85c5327bd3faf55536817a1 to your computer and use it in GitHub Desktop.
Operator allowing for chaining - piping - "jobs" together.
precedencegroup Pipe {
higherThan: DefaultPrecedence
associativity: left
assignment: true
}
infix operator |>: Pipe
func |> <J>(input: J.Input, job: J) throws -> J.Output where J: Job {
try job.work(input: input)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment