floats: fix floats.Slice truncate

This commit is contained in:
c9s 2023-06-01 11:43:22 +08:00
parent e320e5d249
commit 9c43c75361
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -192,7 +192,7 @@ func (s Slice) Last(i int) float64 {
} }
func (s Slice) Truncate(size int) Slice { func (s Slice) Truncate(size int) Slice {
if len(s) < size { if size < 0 || len(s) <= size {
return s return s
} }