"""An error-handling model influenced by that used by the Rust programming languageSee https://doc.rust-lang.org/book/ch09-00-error-handling.html."""fromtypingimportGeneric,TypeVar,UnionT=TypeVar("T")E=TypeVar("E",bound=Exception)classOk(Generic[T]):def__init__(self,value:T)->None:self._value=valuedefok(self)->T:returnself._valueclassErr(Generic[E]):def__init__(self,e:E)->None:self._e=edeferr(self)->E:returnself._eResult=Union[Ok[T],Err[E]]