RTrimSlice Right trims the given slice by given length
(v []T, trimLen int)
| 190 | |
| 191 | // RTrimSlice Right trims the given slice by given length |
| 192 | func RTrimSlice[T any](v []T, trimLen int) []T { |
| 193 | if trimLen >= len(v) { // trimLen greater than slice len means fully sliced |
| 194 | return v[:0] |
| 195 | } |
| 196 | if trimLen < 0 { // negative trimLen is ignored |
| 197 | return v[:] |
| 198 | } |
| 199 | return v[:len(v)-trimLen] |
| 200 | } |
no outgoing calls