Skip to content

[Proposal] SF-0010 Amend proposal to make types Hashable #972

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

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Proposals/0010-calendar-recurrence-rule-end-count-and-date.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Author(s): Hristo Staykov <[email protected]>
* Review Manager: [Tina Liu](https://github.com/itingliu)
* Status: **Implemented**
* Bugs: <rdar://134294130>
* Bugs: <rdar://134294130&136704624>
* Implementation: [apple/swift-foundation#888](https://github.com/apple/swift-foundation/pull/888)
* Previous Proposal: [SF-0009](0009-calendar-recurrence-rule.md)

Expand All @@ -14,6 +14,7 @@
* **v1** Initial version
* **v2** Added `CustomStringConvertible` conformance to `Calendar.RecurrenceRule.End`.
* **v3** Renamed `count` to `occurrences`
* **v4** Made `Calendar.RecurrenceRule` conform to `Hashable`

## Introduction

Expand Down Expand Up @@ -41,6 +42,8 @@ This is de-facto an enum, but it was declared as struct to be future-proof. Howe

Additionally, we add `CustomStringConvertible` conformance to the struct. Previously, implementation details would be leaked when printing (`End(_guts: Foundation.Calendar.RecurrenceRule.End.(unknown context at $1a0a00afc)._End.never)`).

Lastly, we also make `Calendar.RecurrenceRule` and its subtypes conform to `Hashable`

## Detailed design

```swift
Expand All @@ -66,6 +69,18 @@ public extension Calendar.RecurrenceRule.End: CustomStringConvertible {
}
}
}

@available(FoundationPreview 6.0.2, *)
public extension Calendar.RecurrenceRule: Hashable { }

@available(FoundationPreview 6.0.2, *)
public extension Calendar.RecurrenceRule.End: Hashable { }

@available(FoundationPreview 6.0.2, *)
public extension Calendar.RecurrenceRule.Month: Hashable { }

@available(FoundationPreview 6.0.2, *)
public extension Calendar.RecurrenceRule.Weekday: Hashable { }
```

## Impact on existing code
Expand Down