Swaps value and error types. So, values become errors and errors become values. It is useful when you have to work with errors a lot. And since we have a lot of ``.bind_`` related methods and only a single ``.lash``. It is easier to work with values
(self)
| 672 | return IOResult.from_result(await self._inner_value) |
| 673 | |
| 674 | def swap(self) -> 'FutureResult[_ErrorType_co, _ValueType_co]': |
| 675 | """ |
| 676 | Swaps value and error types. |
| 677 | |
| 678 | So, values become errors and errors become values. |
| 679 | It is useful when you have to work with errors a lot. |
| 680 | And since we have a lot of ``.bind_`` related methods |
| 681 | and only a single ``.lash``. |
| 682 | It is easier to work with values than with errors. |
| 683 | |
| 684 | .. code:: python |
| 685 | |
| 686 | >>> import anyio |
| 687 | >>> from returns.future import FutureSuccess, FutureFailure |
| 688 | >>> from returns.io import IOSuccess, IOFailure |
| 689 | |
| 690 | >>> assert anyio.run(FutureSuccess(1).swap) == IOFailure(1) |
| 691 | >>> assert anyio.run(FutureFailure(1).swap) == IOSuccess(1) |
| 692 | |
| 693 | """ |
| 694 | return FutureResult(_future_result.async_swap(self._inner_value)) |
| 695 | |
| 696 | def map( |
| 697 | self, |
nothing calls this directly
no test coverage detected