-
Notifications
You must be signed in to change notification settings - Fork 447
Add new FiniteCycle
type as the return type of Collection.cycled(times:)
#106
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
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c636b09
[test] Divide up existing Cycle tests and add FiniteCycle placeholder…
LemonSpike b4d0636
Implement FiniteCycle with Iterator wrapper around Product2 Iterator.
LemonSpike 70a2c56
Change method signature of cycled(times:) to use new FiniteCycle.
LemonSpike 3488868
Add tuple labels to Product2 for clarity.
LemonSpike a38d07a
Apply column 80 width consistently.
LemonSpike fc2cdc1
Make base and times internal to avoid future Equatable issues.
LemonSpike 4c4e36f
Refactor times and base to single Product2 type, and refactor Iterator.
LemonSpike 9f63577
Add Collection, BidrectionalCollection and RandomAccessCollection con…
LemonSpike c257737
Add tests for index methods on FiniteCycle.
LemonSpike d876f8b
Add new count property to cycle with a test.
LemonSpike 037b09a
Add @inlinable annotations.
LemonSpike 154f738
Remove Sequence conformance for FiniteCycle and add LazyCollectionPro…
LemonSpike 952afb0
Update Cycle.md.
LemonSpike 62abcb4
Add conditional conformances for Equatable and Hashable.
LemonSpike 6073193
Make more @inlinable.
LemonSpike f65f130
Refactor typealias Index into struct, and remove Iterator.
LemonSpike 5527e1d
Make let product internal with @usableFromInline.
LemonSpike 66b6aff
Revert tuple labels.
LemonSpike e583de9
Update documentation descriptions.
LemonSpike File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep this tuple unlabeled —
Zip2Sequence
's element tuple doesn't have labels either, and generic labels such aselement1
andelement2
don't really add any clarity over.0
and.1
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am happy to do this, but I still think that the labels improve readability for users who don't know about tuple indexing. I saw we use more descriptive names for public APIs and type names, so I think it could help users understand the API. Let me know your thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These labels don't improve the users' understanding, because they don't convey any useful information. It's impossible for us to give the tuple elements descriptive names because at this level of abstraction we have nothing to go on. To quote the API Design Guidelines:
Feel free to start a discussion about this topic on the forums, as this is equally relevant to the
Zip2Sequence
element type. For the time being we'd like to stick with the precedent set by the standard library.