Skip to content

Commit

Permalink
Update Readme with a compatibility note.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobg committed Aug 8, 2024
1 parent 9f03b23 commit 1af5821
Showing 1 changed file with 38 additions and 4 deletions.
42 changes: 38 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,44 @@

This is go-generics,
a collection of typesafe generic utilities
for slices, maps, sets, iterators, and goroutine patterns in Go.
for slices, maps, sets, and goroutine patterns in Go.

# Compatibility note

This is version 4 of this library,
for the release of Go 1.23.

Earlier versions of this library included a package,
`iter`,
that defined an iterator type over several types of containers,
and functions for operating with iterators.
However, Go 1.23 defines its own, better iterator mechanism
via the new “range over function” language feature,
plus [a new standard-library package](https://pkg.go.dev/iter) also called `iter`.
This version of the go-generics library therefore does away with its `iter` package.
The handy functions that `iter` contained for working with iterators
(`Filter`, `Map`, `FirstN`, and many more)
can now be found in the [github.com/bobg/seqs](https://pkg.go.dev/github.com/bobg/seqs) library,
adapted for Go 1.23 iterators.

(This version of go-generics might have kept `iter` as a drop-in replacement for the standard-library package,
but was unable because the standard library defines two types,
`iter.Seq[K]` and `iter.Seq2[K, V]`,
that go-generics would have had to reference using type aliases;
but Go type aliases [do not yet permit type parameters](https://github.com/golang/go/issues/46477#issuecomment-2101270785).)

Earlier versions of this library included combinatorial operations in the `slices` package.
Those have now been moved to their own library,
[github.com/bobg/combo](https://pkg.go.dev/github.com/bobg/combo).

Earlier versions of this library included two functions,
`maps.Keys` and `maps.Values`,
for producing a slice of (respectively) the keys of a map and the values of a map.
As of Go 1.23,
the standard library now defines its own `maps.Keys` and `maps.Values`,
producing iterators instead of slices.
This library updates those functions to match
in order for its `maps` to remain a drop-in replacement for the stdlib `maps`.

# Slices

Expand All @@ -20,9 +57,6 @@ The `slices` package is useful in three ways:
- It includes `Map`, `Filter`, and a few other such functions
for processing slice elements with callbacks.

It also includes combinatorial operations:
`Permutations`, `Combinations`, and `CombinationsWithReplacement`.

The `slices` package is a drop-in replacement
for the `slices` package
added to the Go stdlib
Expand Down

0 comments on commit 1af5821

Please sign in to comment.