Skip to content

Instantly share code, notes, and snippets.

@aleksandr-lavrinenko
Last active July 14, 2020 20:40
Show Gist options
  • Select an option

  • Save aleksandr-lavrinenko/5977308e2843aab3879eebf6dc66c253 to your computer and use it in GitHub Desktop.

Select an option

Save aleksandr-lavrinenko/5977308e2843aab3879eebf6dc66c253 to your computer and use it in GitHub Desktop.
precedencegroup ChainOperatorPrecedence {
associativity: left
}
infix operator >>>: ChainOperatorPrecedence
@discardableResult
public func >>> (left: Operation, right: Operation) -> Operation {
right.addDependency(left)
return right
}
@discardableResult
public func >>> (left: Operation, right: [Operation]) -> [Operation] {
for operation in right {
operation.addDependency(left)
}
return right
}
@discardableResult
public func >>> (left: [Operation], right: Operation) -> Operation {
for operation in left {
right.addDependency(operation)
}
return right
}
@discardableResult
public func >>> (left: [Operation], right: [Operation]) -> [Operation] {
assert(!right.isEmpty)
for operationLeft in left {
for operationRight in right {
operationRight.addDependency(operationLeft)
}
}
return right
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment