-
-
Save jasdev/0d5aae487e5982df83ef31948d4ab393 to your computer and use it in GitHub Desktop.
A PrefixInclusiveEvent helper type.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private enum PrefixInclusiveEvent<Output> { | |
/// A signal that upstream should complete successfully after a predicate-failing value. | |
case end | |
/// A signal that the inner associated value either passed the predicate or is the first not to. | |
case predicatePassingValueOrIncluded(Output) | |
/// An [enumeration property](https://www.pointfree.co/episodes/ep52-enum-properties) | |
/// to check if `self` is a `predicatePassingValueOrIncluded` event. | |
var isPredicatePassingValueOrIncluded: Bool { | |
guard case .predicatePassingValueOrIncluded = self else { return false } | |
return true | |
} | |
/// An enumeration property for quick access to the output value, if present. | |
var output: Output? { | |
guard case let .predicatePassingValueOrIncluded(inner) = self else { return nil } | |
return inner | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment