Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,11 @@ However, `Future` still requires to be executed inside a proper eventloop:

```python
import anyio # or asyncio, or any other lib
from returns.io import IO

# We can then pass our `Future` to any library: asyncio, trio, curio.
# And use any event loop: regular, uvloop, even a custom one, etc
assert anyio.run(second().awaitable) == 2
assert anyio.run(second().awaitable) == IO(2)
```

As you can see `Future` allows you
Expand Down Expand Up @@ -579,8 +580,9 @@ async def raising():
raise ValueError('Not so fast!')


ioresult = anyio.run(raising.awaitable) # all `Future`s return IO containers
assert ioresult == IOFailure(ValueError('Not so fast!')) # True
ioresult = anyio.run(raising().awaitable) # all `Future`s return IO containers
assert isinstance(ioresult, IOFailure)
assert str(ioresult) == '<IOResult: <Failure: Not so fast!>>'
```

Using `FutureResult` will keep your code safe from exceptions.
Expand Down
Loading