aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'pomu/util/result.py')
-rw-r--r--pomu/util/result.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/pomu/util/result.py b/pomu/util/result.py
index cd67fa0..d6933d8 100644
--- a/pomu/util/result.py
+++ b/pomu/util/result.py
@@ -55,6 +55,19 @@ class Result():
return self._val
raise ResultException(msg + ': ' + self._val)
+ def and_(self, rhs):
+ if not self.is_ok():
+ return Result.Err(self.err())
+ return rhs
+
+ def and_then(self, f):
+ return self.map(f)
+
+ def or_(self, rhs):
+ if self.is_ok():
+ return Result.Ok(self.ok())
+ return rhs
+
def __iter__(self):
if self._is_val:
yield self._val