Download lib/python3.9/site-packages/black/rusty.py from camenduru/slahmr-test: direct link, hf CLI and curl.
- Browser
- Download file 556 Bytes
-
https://huggingface.co/camenduru/slahmr-test/resolve/main/lib/python3.9/site-packages/black/rusty.py
- Command line
-
hf download hf://camenduru/slahmr-test/lib/python3.9/site-packages/black/rusty.py
-
curl -L -o rusty.py https://huggingface.co/camenduru/slahmr-test/resolve/main/lib/python3.9/site-packages/black/rusty.py
556 Bytes
| """An error-handling model influenced by that used by the Rust programming language | |
| See https://doc.rust-lang.org/book/ch09-00-error-handling.html. | |
| """ | |
| from typing import Generic, TypeVar, Union | |
| T = TypeVar("T") | |
| E = TypeVar("E", bound=Exception) | |
| class Ok(Generic[T]): | |
| def __init__(self, value: T) -> None: | |
| self._value = value | |
| def ok(self) -> T: | |
| return self._value | |
| class Err(Generic[E]): | |
| def __init__(self, e: E) -> None: | |
| self._e = e | |
| def err(self) -> E: | |
| return self._e | |
| Result = Union[Ok[T], Err[E]] | |