From d9ebaf20f8e71f043d2387a42d273dadc5d536b5 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sat, 24 Jan 2026 11:48:19 +0900 Subject: internal/rosa: stage3 special case helper This makes it cleaner to specify non-stage3 and stage3-exclusive dependencies. Signed-off-by: Ophestra --- internal/rosa/rosa.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'internal/rosa/rosa.go') diff --git a/internal/rosa/rosa.go b/internal/rosa/rosa.go index 06f73c67..c3b6a3ed 100644 --- a/internal/rosa/rosa.go +++ b/internal/rosa/rosa.go @@ -116,6 +116,24 @@ const ( Std ) +// stage3Concat concatenates s and values. If the current toolchain is +// toolchainStage3, stage3Concat returns s as is. +func stage3Concat[S ~[]E, E any](t Toolchain, s S, values ...E) S { + if t == toolchainStage3 { + return s + } + return slices.Concat(s, values) +} + +// stage3ExclConcat concatenates s and values. If the current toolchain is not +// toolchainStage3, stage3ExclConcat returns s as is. +func stage3ExclConcat[S ~[]E, E any](t Toolchain, s S, values ...E) S { + if t == toolchainStage3 { + return slices.Concat(s, values) + } + return s +} + // lastIndexFunc is like [strings.LastIndexFunc] but for [slices]. func lastIndexFunc[S ~[]E, E any](s S, f func(E) bool) (i int) { if i = slices.IndexFunc(s, f); i < 0 { -- cgit v1.3.1