Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/black/rusty.py: 73%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""An error-handling model influenced by that used by the Rust programming language
3See https://doc.rust-lang.org/book/ch09-00-error-handling.html.
4"""
6from typing import Generic, TypeVar, Union
8T = TypeVar("T")
9E = TypeVar("E", bound=Exception)
12class Ok(Generic[T]):
13 def __init__(self, value: T) -> None:
14 self._value = value
16 def ok(self) -> T:
17 return self._value
20class Err(Generic[E]):
21 def __init__(self, e: E) -> None:
22 self._e = e
24 def err(self) -> E:
25 return self._e
28Result = Union[Ok[T], Err[E]]