Relax generic constraint of array operator from Collection to Sequence#636
Relax generic constraint of array operator from Collection to Sequence#636omochi wants to merge 1 commit intovapor:mainfrom
Collection to Sequence#636Conversation
|
I seem to remember that there was a reason I didn't do this last time I was tinkering with the value operators, but unfortunately I don't remember what that reason was. At the very least, there is definitely a conceptual issue in that I don't think this was the only reason I didn't do it, though - there's definitely very obvious utility in allowing the use of algorithms such as I need to investigate this a bit further before making a final decision, but I should say that I'm leaning towards avoiding it, if only out of an abundance of caution. |
|
Regarding the risk of infinite length with It’s true that, strictly speaking, this change is not source-compatible. |
Changes
The array operator
~~is currently defined to take aCollectionas its right-hand side operand, but aSequenceis 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
Sequencesthat are notCollections, such as.uniqued()fromswift-algorithms, so being able to usesome Sequenceis convenient.Compatibility
Since
Collectionis a sub-protocol ofSequence, this change to the generic signature is a pure relaxation and remains fully source-compatible.