-
-
Save jasdev/0f5f36ae0cbea851eb4ac37e9635e30e to your computer and use it in GitHub Desktop.
`setFailureType` setup with `Just`.
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
import Combine | |
/// (1) A sample error type we’ll try to promote `Never` to. | |
enum OurError: Error { | |
case anError | |
} | |
Just(6_174) /// (2) [`Just<Int>.Failure == Never`](https://developer.apple.com/documentation/combine/just/failure). | |
.mapError { /* `(Never) -> OurError` */ } /// (3) This is…awkward. `mapError` accepts an `(Failure) -> E` | |
/// closure for some new `Error`-conforming type, `E`. But, this block is never executed since, | |
/// well, there aren’t any `Never` instances to call it with. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment