From 573c398f767574cf59d955914e0452171f232021 Mon Sep 17 00:00:00 2001 From: Timon Ringwald Date: Thu, 24 Feb 2022 21:11:35 +0100 Subject: [PATCH] cursor is closable --- cursor.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cursor.go b/cursor.go index 4eccd7e..ed680f9 100644 --- a/cursor.go +++ b/cursor.go @@ -13,6 +13,10 @@ func (c Cursor[T]) First() *T { return <-c.Chan } +func (c Cursor[T]) Close() { + defer c.cancelFunc() +} + func (c Cursor[T]) Next() (*T, bool) { if c.ctx.Err() == nil { value, ok := <-c.Chan