BooleanCat / go-functional

go-functional is a library of iterators to augment the standard library
MIT License
405 stars 23 forks source link

[Feature 🔨]: Add `iter.Once(foo)` iterator #118

Closed BooleanCat closed 2 months ago

BooleanCat commented 2 months ago

Is your feature request related to a problem? Please describe.

Rust provides the once() iterator that simply creates an iterator that yields the provided element once. It's synonymous with something like slices.Values([]string{"foo"}).

Describe the solution you'd like

See above.

Provide code snippets to show how this new feature might be used.

fmt.Println(slices.Collect(iter.Once("foo")))
// Output: [foo]

Does this incur a breaking change?

No.

Do you intend to build this feature yourself?

Yes.