Skip to content
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

[SR-9407] CollectionOfOne should conditionally conform to Equatable and Hashable #51873

Open
nsalmoria opened this issue Dec 4, 2018 · 4 comments
Labels
improvement standard library Area: Standard library umbrella

Comments

@nsalmoria
Copy link
Contributor

Previous ID SR-9407
Radar None
Original Reporter @nsalmoria
Type Improvement
Additional Detail from JIRA
Votes 1
Component/s Standard Library
Labels Improvement
Assignee None
Priority Medium

md5: 990969e5f9342f860fe40141f06a1cc5

Issue Description:

When conditional conformance was added to the language, most collection types were updated to conditionally conform to Equatable and Hashable when their Elements conform.

I think CollectionOfOne was left out just by oversight, since conformance would be trivial.

Similarly, EmptyCollection unconditionally conforms to Equatable, but it doesn't conform to Hashable. Arguably, the usefulness of the latter would be limited, but still it would make sense for consistency.

I'm not sure if this needs to pass through Swift Evolution approval.

@belkadan
Copy link
Contributor

belkadan commented Dec 4, 2018

cc @lorentey

@nsalmoria
Copy link
Contributor Author

Also, conformance to Encodable/Decodable should be considered. I presume that most of the issues that are afflicting the current evaluation of Range conformance shouldn't apply to CollectionOfOne and EmptyCollection.

@belkadan
Copy link
Contributor

I don't know if those make sense. You're not intended to persist a CollectionOfOne or an EmptyCollection; they're for interacting with APIs that require a collection to do anything.

@nsalmoria
Copy link
Contributor Author

Well, I had a use case with an associatedtype representing the elements (equivalence classes) of a quotient set, and CollectionOfOne was the perfect default.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

2 participants