feat: introduce slice-backed v3 API - #6
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Collection v3 is now a Go 1.27-native, slice-backed API at
github.com/goforj/collection/v3.Slice[T]is a named slice, so it works directly withlen, indexing, slicing,range, standard-library helpers, and iterator adapters. Generic methods now support type-changing fluent operations, while mutating hot paths remain explicit and allocation-free throughTransformandRetain.Every exported function and method has an executable example generated from its GoDoc. The complete method-by-method migration, including removed APIs and ownership changes, is in MIGRATING_TO_V3.md.
Module path
Before
After
Items
Before
After
ItemsCopy
Before
After
Map
Before
After
Transform
Before
After
Filter
Before
After
Retain
Before
After
Concat
Before
After
Why
Go 1.27 generic methods remove the compromise that shaped v2. The API can stay fluent while changing element types, without wrapper accessors, duplicate free functions, or specialized numeric collection types.
The result feels like ordinary Go: use native slice syntax when that is clearest, fluent methods when they improve readability, and explicit in-place methods in hot paths. v2 remains available for existing consumers, while v3 provides the clean major-version boundary needed to make those semantics consistent.
The benchmark suite now restores mutable input on every measured iteration for both implementations. Matched v2/v3 regression benchmarks cover mutable
Retain,Transform, andShufflepaths plus input-preserving Filter and pipeline workloads. The hot paths remain zero-allocation, while the generated README tables and regression module make broader performance and ownership trade-offs visible.