summaryrefslogtreecommitdiff
path: root/AK/Try.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-11-10 11:54:54 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-10 21:58:58 +0100
commitcd49f30bea734feb9ac46d637e2ed3439e47e3c3 (patch)
treefd2b1f85385d09b383f6c3ac3e694f3834a7e7f3 /AK/Try.h
parent5f7d008791f9e358638283dc2f0d709a601344ff (diff)
downloadserenity-cd49f30bea734feb9ac46d637e2ed3439e47e3c3.zip
AK+LibJS: Simplify MUST() and move it from LibJS to AK/Try.h
This is generally useful so let's move it to AK. Also it seems that we don't need the temporary variable hack anymore, so let's lose that.
Diffstat (limited to 'AK/Try.h')
-rw-r--r--AK/Try.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/AK/Try.h b/AK/Try.h
index 15d470e86b..8db09a950a 100644
--- a/AK/Try.h
+++ b/AK/Try.h
@@ -16,3 +16,10 @@
return _temporary_result.release_error(); \
_temporary_result.release_value(); \
})
+
+#define MUST(expression) \
+ ({ \
+ auto _temporary_result = (expression); \
+ VERIFY(!_temporary_result.is_error()); \
+ _temporary_result.release_value(); \
+ })