Relax generic constraint of array operator from Collection
to Sequence
#636
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.
Changes
The array operator
~~
is currently defined to take aCollection
as its right-hand side operand, but aSequence
is sufficient, so this constraint is relaxed.Motivation
With this change, it becomes convenient to use the operator with values like some
Sequence
, for example:In server-side data manipulation logic, it’s common to use
Sequences
that are notCollections
, such as.uniqued()
fromswift-algorithms
, so being able to usesome Sequence
is convenient.Compatibility
Since
Collection
is a sub-protocol ofSequence
, this change to the generic signature is a pure relaxation and remains fully source-compatible.