aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/result.hpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/result.hpp b/src/result.hpp
index b740a0c..5701f24 100644
--- a/src/result.hpp
+++ b/src/result.hpp
@@ -30,14 +30,14 @@ struct result {
return this->t.value();
}
- operator T() {
- return this->unwrap();
- }
+ operator T() { return this->unwrap(); }
char const *unwrap_err() { return this->e; }
- optional<T> ok() const { return this->t; }
- optional<char const *> err() const { return optional<char const *>(this->e); }
+ optional<T> const &ok() const { return this->t; }
+ optional<char const *> err() const {
+ return this->e ? optional<char const *>(this->e) : nullopt;
+ }
result<T> map_err(std::function<char const *(char const *)> f);
};