From 4bbac728682492efd66e57acaa56c3fdd858868b Mon Sep 17 00:00:00 2001 From: Joe Tsai Date: Thu, 4 Apr 2024 14:38:16 -0700 Subject: [PATCH] util/truncate: support []byte as well (#11614) There are no mutations to the input, so we can support both ~string and ~[]byte just fine. Updates #cleanup Signed-off-by: Joe Tsai --- util/truncate/truncate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/truncate/truncate.go b/util/truncate/truncate.go index b13dc6f10..310b81dd0 100644 --- a/util/truncate/truncate.go +++ b/util/truncate/truncate.go @@ -9,7 +9,7 @@ // bytes. If s exceeds this length, it is truncated at a point ≤ n so that the // result does not end in a partial UTF-8 encoding. If s is less than or equal // to this length, it is returned unmodified. -func String(s string, n int) string { +func String[String ~string | ~[]byte](s String, n int) String { if n >= len(s) { return s }