-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: x/exp/xiter: add Nop, Nop2, Value, Value2 #68947
Comments
Quick idea is to generalize to +0 elements. A I am not sure there is a good matching generalization for +0 pairs. |
In my experiments with iterators I called these (type parameters and packages elided for brevity) |
xiter has Concat, which can be used for Nop by just doing |
Our xiter package contains: // One returns an iterator that yields the single element x.
func One[T any](x T) iter.Seq[T]
// Empty returns an iterator that yields no values.
func Empty[T any]() iter.Seq[T] Just more evidence that these are widespread and useful. Looking through our uses, a single variadic function as proposed by @timothy-king would work fine as well. |
Proposal Details
This could probably go in golang.org/x/exp/xiter for now, but it should also be considered for plain package iter.
Nop yields an empty (no op) sequence. Nop2 yields an empty iter.Seq2.
Value2
isn't a great name, but seems the most straightforward.See #68931, #65629 and I forget where iter.Value first came up.
The text was updated successfully, but these errors were encountered: