From 8ded84a1a0adc12292bd1ee0a7fdfda00764d810 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Tue, 30 Jul 2024 18:44:11 +0100 Subject: [PATCH] 2024-07-29/02: add must2 --- 2024-07-29/02-go-a-reasonable-good-language.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/2024-07-29/02-go-a-reasonable-good-language.md b/2024-07-29/02-go-a-reasonable-good-language.md index d74548a..ab995c2 100644 --- a/2024-07-29/02-go-a-reasonable-good-language.md +++ b/2024-07-29/02-go-a-reasonable-good-language.md @@ -93,7 +93,12 @@ func must1[T any](v T, err error) T { return v } -// must2, must3, etc... +func must2[T1 any, T2 any](v1 T1, v2 T2, err error) T { + must(err) + return v1, v2 +} + +// must3, must4, etc... ``` Those functions are so useful, especially for scripts where I generally don't