init
This commit is contained in:
commit
38355d2442
9083 changed files with 1225834 additions and 0 deletions
28
.venv/lib/python3.8/site-packages/black/rusty.py
Normal file
28
.venv/lib/python3.8/site-packages/black/rusty.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
"""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]]
|
||||
Loading…
Add table
Add a link
Reference in a new issue