]> crepu.dev Git - config.git/blob - djavu-asus/elpy/rpc-venv/lib/python3.11/site-packages/black/rusty.py
ActualizaciĆ³n de Readme
[config.git] / djavu-asus / elpy / rpc-venv / lib / python3.11 / site-packages / black / rusty.py
1 """An error-handling model influenced by that used by the Rust programming language
2
3 See https://doc.rust-lang.org/book/ch09-00-error-handling.html.
4 """
5 from typing import Generic, TypeVar, Union
6
7 T = TypeVar("T")
8 E = TypeVar("E", bound=Exception)
9
10
11 class Ok(Generic[T]):
12 def __init__(self, value: T) -> None:
13 self._value = value
14
15 def ok(self) -> T:
16 return self._value
17
18
19 class Err(Generic[E]):
20 def __init__(self, e: E) -> None:
21 self._e = e
22
23 def err(self) -> E:
24 return self._e
25
26
27 Result = Union[Ok[T], Err[E]]