From e2502a2e835e9b6f230a5fc2fc7d198f9892cd6c Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 5 Jan 2025 16:40:10 +0800 Subject: misc: Pointerize_first --- misc/misc.go | 7 +++++++ 1 file changed, 7 insertions(+) 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 { -- cgit v1.2.3