Open ffried opened 8 months ago
These kinds of wrapper collections typically aren't mutable – for example, when you called reversed()
on an array, the elements of the resulting ReversedCollection
aren't mutable, even if your original array is.
That said, I don't think it's necessarily the wrong thing to do here – in general the first mutation will make a copy of whichever base collection ends up getting modified, and from then it will be singly referenced. I've started a discussion in the forums to talk about the question – please add any more thoughts you have: https://forums.swift.org/t/making-collection-wrappers-mutable/69142
Is there a specific reason why Chain2Sequence does not conform to
MutableCollection
whenBase1
andBase2
do?I'm trying to build an API that uses two
some MutableCollection<T>
as parameters and one as return value. I need it to be mutable, because I need to change a specific element in the collection. Internally, the parameters will be chained usingchain(_:_:)
- or at least that's the goal.I'm happy to provide a PR for this, but I wanted to see if there's a reason against it first.