dnscontrol/pkg/diff2/highest.go

8 lines
223 B
Go
Raw Normal View History

package diff2
2023-01-29 00:09:38 +08:00
// highest returns the highest valid index for an array. The equiv of len(s)-1, but with
// less likelihood that you'll commit an off-by-one error.
func highest[S ~[]T, T any](s S) int {
return len(s) - 1
}