aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-01-05 16:40:10 +0800
committerRunxi Yu <me@runxiyu.org>2025-01-05 16:40:10 +0800
commite2502a2e835e9b6f230a5fc2fc7d198f9892cd6c (patch)
tree48fb3d760680fdfdad9749374f88876cc2d8d596
parentmisc: Make Dir_t.Close() a method (diff)
downloadgo-lindenii-common-e2502a2e835e9b6f230a5fc2fc7d198f9892cd6c.tar.gz
go-lindenii-common-e2502a2e835e9b6f230a5fc2fc7d198f9892cd6c.tar.zst
go-lindenii-common-e2502a2e835e9b6f230a5fc2fc7d198f9892cd6c.zip
misc: Pointerize_first
-rw-r--r--misc/misc.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/misc/misc.go b/misc/misc.go
index 572651f..95fa405 100644
--- a/misc/misc.go
+++ b/misc/misc.go
@@ -6,6 +6,13 @@ import (
"strings"
)
+// Pointerize_first returns the address of its first argument, and the value of
+// its second argument. This is useful to for taking the address of a function
+// that also has an error return value.
+func Pointerize_first[T1 any, T2 any](x1 T1, x2 T2) (*T1, T2) {
+ return &x1, x2
+}
+
// Copy_map the map src to dst without clearing existing items in dst.
func Copy_map[K comparable, V any](dst map[K]V, src map[K]V) {
for k, v := range src {