From b79eeea0db34bd128866e7e5f8f5bb106cc738ad Mon Sep 17 00:00:00 2001 From: Ophestra Date: Mon, 14 Jul 2025 22:34:44 +0900 Subject: [PATCH] instantiated: rename Drv method to Instantiated This avoids confusion with actual derivation structs. --- instantiated.go | 6 +++--- instantiated_test.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/instantiated.go b/instantiated.go index f11230e..44e4696 100644 --- a/instantiated.go +++ b/instantiated.go @@ -72,8 +72,8 @@ func NewInstantiatedDecoder(r io.Reader) *InstantiatedDecoder { return &InstantiatedDecoder{scanner: bufio.NewScanner(r)} } -// Drv returns a non-reusable iterator over instantiated derivations collected from [io.Reader]. -func (d *InstantiatedDecoder) Drv() iter.Seq[string] { +// Instantiated returns a non-reusable iterator over instantiated derivations collected from [io.Reader]. +func (d *InstantiatedDecoder) Instantiated() iter.Seq[string] { return func(yield func(string) bool) { for d.scanner.Scan() { v := d.scanner.Text() @@ -114,7 +114,7 @@ func (d *InstantiatedDecoder) Drv() iter.Seq[string] { // Decode collects and deduplicates derivations emitted by [InstantiatedDecoder]. func (d *InstantiatedDecoder) Decode() ([]string, error) { instantiated := make([]string, 0, instantiatedInitialCap) - for drv := range d.Drv() { + for drv := range d.Instantiated() { if len(instantiated) == cap(instantiated) { // grow the buffer exponentially to minimise copies instantiated = slices.Grow(instantiated, cap(instantiated)<<1) diff --git a/instantiated_test.go b/instantiated_test.go index ecb4c36..1c775d3 100644 --- a/instantiated_test.go +++ b/instantiated_test.go @@ -74,7 +74,7 @@ func TestDecodeInstantiated(t *testing.T) { decoder := nixbuild.NewInstantiatedDecoder(strings.NewReader(segmentPrefix + segmentBody + segmentSuffix)) counter := 3 got := make([]string, 0, counter) - for drv := range decoder.Drv() { + for drv := range decoder.Instantiated() { got = append(got, drv) counter-- if counter == 0 { @@ -83,7 +83,7 @@ func TestDecodeInstantiated(t *testing.T) { } if !slices.Equal(got, want) { - t.Errorf("Drv: %#v, want %#v", got, want) + t.Errorf("Instantiated: %#v, want %#v", got, want) } })