Skip to content

V2 API

Compare
Choose a tag to compare
@bobg bobg released this 19 Mar 15:36
· 19 commits to master since this release
9091c40

What's Changed

This update to the API has parity with golang.org/x/exp/slices and golang.org/x/exp/maps (which will become part of the stdlib in Go 1.21).

Generic declarations are more correct. Whereas in v1 we had e.g.:

func Get[T any](s []T, idx int) T { ... }

(which allows Get to take a []T only)

now we have:

func Get[S ~[]T, T any](s S, idx int) T { ... }

(which allows Get to take a []T and any type defined as []T).

Combinatorics functions are now in the slices package.

Several functions taking callbacks now have a Function form and a Functionx ("extended") form. The first one takes a simpler callback for greater ergonomics. The second one takes a more thorough callback. For example, the callback in slices.Map takes a single argument of type T and returns a single value of type U, while the callback in slices.Mapx takes an index and a T, and returns a U and an error.

Pull requests are now checked by golangci-lint.

Full Changelog: v1.7.2...v2.1.1

(Note: this is v2.1.1 of this module. An earlier v2.0.0 has been retracted.)