From d6173c8675baa8a7596b7164f5d453a7961f2eeb Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Fri, 26 Jun 2026 20:38:01 +0000 Subject: [PATCH] make SafeUint64 generic --- units.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/units.go b/units.go index 59029d1..24edd60 100644 --- a/units.go +++ b/units.go @@ -50,7 +50,8 @@ func FormatNumber(val uint64, base uint64) (string, string) { } } -func SafeUint64(i int) uint64 { +// Converts int, int32, and int64 to uint64. Less than 0 check. +func SafeUint64[I int | int32 | int64](i I) uint64 { if i < 0 { log.Printf("Tried to cast %d to uint64", i) return 0