aboutsummaryrefslogtreecommitdiff
path: root/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'util.go')
-rw-r--r--util.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/util.go b/util.go
new file mode 100644
index 0000000..34cf28b
--- /dev/null
+++ b/util.go
@@ -0,0 +1,9 @@
+package core
+
+// Must panics if err is not nil. It returns val otherwise.
+func Must[T any](val T, err error) T {
+ if err != nil {
+ panic(err)
+ }
+ return val
+}