From 7d930b6e97891a4b576b338c2e2dde627c3bab95 Mon Sep 17 00:00:00 2001 From: ScuroNeko Date: Wed, 4 Feb 2026 12:56:22 +0300 Subject: [PATCH] fix Pop method --- slice.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/slice.go b/slice.go index 4a3e820..484cd61 100644 --- a/slice.go +++ b/slice.go @@ -50,12 +50,12 @@ func (s Slice[T]) Pop(index int) Slice[T] { if index == 0 { return s[1:] } - out := make(Slice[T], s.Len()-index) + out := make(Slice[T], 0, s.Len()-1) for i, e := range s { if i == index { continue } - out[i] = e + out = append(out, e) } return out } @@ -132,12 +132,12 @@ func (s Set[T]) Pop(index int) Set[T] { if index == 0 { return s[1:] } - out := make(Set[T], s.Len()-index) + out := make(Set[T], 0, s.Len()-1) for i, e := range s { if i == index { continue } - out[i] = e + out = append(out, e) } return out }