from typing import AsyncGenerator
from typing import Any


async def _anext(gen: AsyncGenerator[Any, Any], default: Any) -> Any:
    """Provide the functionality of python 3.10's `anext()`.

    https://docs.python.org/3/library/functions.html#anext
    """
    try:
        return await gen.__anext__()
    except StopAsyncIteration:
        return default