Skip to content

proposal: iter: Add Contains #68945

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

Closed
adamroyjones opened this issue Aug 19, 2024 · 1 comment
Closed

proposal: iter: Add Contains #68945

adamroyjones opened this issue Aug 19, 2024 · 1 comment
Labels
Milestone

Comments

@adamroyjones
Copy link

Proposal Details

I propose a tiny, but I think helpful, addition to the iter package.

func Contains[K comparable](seq iter.Seq[K], val K) bool {
	for k := range seq {
		if k == val {
			return true
		}
	}
	return false
}

This avoids the need to collect the iter.Seq[K] into a slice.

This could be extended to ContainsFunc.

It could also be extended to Contains2 and Contains2Func, but that may be a bit more strained.

@gopherbot gopherbot added this to the Proposal milestone Aug 19, 2024
@seankhliao
Copy link
Member

Duplicate of #67453

@seankhliao seankhliao marked this as a duplicate of #67453 Aug 19, 2024
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants