Binds a function returning ``Future[a]`` container. .. code:: python >>> import anyio >>> from returns.io import IOSuccess, IOFailure >>> from returns.future import Future, FutureResult >>> def bind(inner_value: int) -> Future[float]:
(
self,
function: Callable[[_ValueType_co], Future[_NewValueType]],
)
| 996 | ) |
| 997 | |
| 998 | def bind_future( |
| 999 | self, |
| 1000 | function: Callable[[_ValueType_co], Future[_NewValueType]], |
| 1001 | ) -> 'FutureResult[_NewValueType, _ErrorType_co]': |
| 1002 | """ |
| 1003 | Binds a function returning ``Future[a]`` container. |
| 1004 | |
| 1005 | .. code:: python |
| 1006 | |
| 1007 | >>> import anyio |
| 1008 | >>> from returns.io import IOSuccess, IOFailure |
| 1009 | >>> from returns.future import Future, FutureResult |
| 1010 | |
| 1011 | >>> def bind(inner_value: int) -> Future[float]: |
| 1012 | ... return Future.from_value(inner_value + 0.5) |
| 1013 | |
| 1014 | >>> assert anyio.run( |
| 1015 | ... FutureResult.from_value(1).bind_future(bind).awaitable, |
| 1016 | ... ) == IOSuccess(1.5) |
| 1017 | >>> assert anyio.run( |
| 1018 | ... FutureResult.from_failure(1).bind_future(bind).awaitable, |
| 1019 | ... ) == IOFailure(1) |
| 1020 | |
| 1021 | """ |
| 1022 | return FutureResult( |
| 1023 | _future_result.async_bind_future( |
| 1024 | function, |
| 1025 | self._inner_value, |
| 1026 | ) |
| 1027 | ) |
| 1028 | |
| 1029 | def bind_async_future( |
| 1030 | self, |
nothing calls this directly
no test coverage detected