Project is now named Celeste
This commit is contained in:
parent
87917f9526
commit
269092fb53
45 changed files with 1507 additions and 12 deletions
19
celeste/structs/__result.py
Normal file
19
celeste/structs/__result.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
from enum import Enum
|
||||
from typing import Optional
|
||||
|
||||
class Result:
|
||||
def __init__(self,
|
||||
success: bool,
|
||||
reason: str,
|
||||
value: Optional[any] = None) -> None:
|
||||
self.success = success
|
||||
self.reason = reason
|
||||
self.value = value
|
||||
|
||||
@classmethod
|
||||
def succeed(cls, value: any, reason: str = 'Ok') -> 'Result':
|
||||
return cls(True, reason, value=value)
|
||||
|
||||
@classmethod
|
||||
def fail(cls, reason: str, value: Optional[any] = None) -> 'Result':
|
||||
return cls(False, reason, value=value)
|
||||
Loading…
Add table
Add a link
Reference in a new issue