Skip to content

Conversation

bobg
Copy link
Owner

@bobg bobg commented Jun 9, 2025

This PR adds functions Rindex, RindexFunc, PrefixFunc, and SuffixFunc in the slices package.

@bobg bobg requested a review from Copilot June 9, 2025 13:27
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces four new functions—Rindex, RindexFunc, PrefixFunc, and SuffixFunc—to the slices package, enhancing slice manipulation capabilities. In addition, the PR updates corresponding tests and adjusts a Consumers callback in another package.

  • Adds PrefixFunc, Rindex, RindexFunc, and SuffixFunc with their associated logic.
  • Updates slice tests to verify the new functions.
  • Modifies a Consumers callback signature in the parallel package to ignore an unused parameter.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
slices/slices.go Introduces new slice processing functions and internal helper invert.
slices/slice_test.go Implements tests for PrefixFunc, SuffixFunc, and Rindex.
parallel/parallel_test.go Updates the Consumers callback with improved parameter usage.
Comments suppressed due to low confidence (2)

slices/slices.go:218

  • [nitpick] Consider adding a brief comment to the 'invert' function to clarify that it returns the logical negation of the provided predicate.
func invert[T any](pred func(T) bool) func(T) bool {

parallel/parallel_test.go:60

  • [nitpick] Include a comment inside the lambda function to indicate that the second parameter is intentionally ignored.
sendfn, closefn := Consumers(context.Background(), 10, func(_ context.Context, _, val int) error {

@coveralls
Copy link

coveralls commented Jun 9, 2025

Pull Request Test Coverage Report for Build 15535747019

Details

  • 28 of 28 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.5%) to 91.241%

Totals Coverage Status
Change from base Build 12770668661: 0.5%
Covered Lines: 500
Relevant Lines: 548

💛 - Coveralls

Copy link

github-actions bot commented Jun 9, 2025

Modver result

This report was generated by Modver,
a Go package and command that helps you obey semantic versioning rules in your Go module.

This PR requires (at least) an increase in your module's minor version number.

no object PrefixFunc in old version of package github.com/bobg/go-generics/v4/slices
  Minor

@bobg bobg merged commit 2413cff into master Jun 9, 2025
3 checks passed
@bobg bobg deleted the bobg/rindex-rindexfunc-prefixfunc-suffixfunc branch June 9, 2025 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants