diff --git a/find.go b/find.go index e516949..006fdcc 100644 --- a/find.go +++ b/find.go @@ -10,8 +10,8 @@ func FindFirst[T any](source <-chan T) *T { } func FindFirstAndCancel[T any](source <-chan T, cancel context.CancelFunc) *T { + defer cancel() for v := range source { - cancel() return &v } return nil