This struck me as a slightly curious omission, given that IndexSet itself is from Foundation. The documentation lists the method under the standard library, which is a bit misleading, given that it cannot be used without importing SwiftUI.
A similar discussion came up a while ago regarding the related move(fromOffsets:toOffset:).
Since these methods feel rather fundamental, and many apps likely already depend on them, is there a reason why they aren't upstreamed to the standard library or Foundation?
Can you clarify what you think should be improved here?
The documentation should not include remove(atOffsets:) and move(fromOffsets:toOffset:) under RangeReplaceableCollection's documentation page
Foundation should provide remove(atOffsets:) and move(fromOffsets:toOffset:) as an API
Foundation should host all extensions on RangeReplaceableCollection and IndexSet exposed by Apple frameworks
I think the reason for these not being in Foundation is simply that these extensions often stemmed from individual frameworks's use cases. There isn't necessarily reasons to exclude them, but frameworks are also free to include them in their own frameworks.
On the open source side of things, it would be nice if DocC's generated documentation could clarify that something is an extension, at least when it's defined outside of the original module's types (e.g. each module/framework could have its own "extensions" page for each extended type, in this case RangeReplaceableCollection, also to make it clear what the consumer needs to import).
On the closed source side, it would be cool if the frameworks could upstream their extensions, if they are general enough in their use case. Since publishing it as part of an Apple framework like SwiftUI already represents a commitment to stability, the whole API design is already mostly set in stone anyway. But if that isn't feasible, perhaps the community could implement these functions upstream, until they land in a stable release, at which point the closed-source frameworks could remove their extensions.
I was just wondering why Array.remove(atOffsets:) is not available in one of my projects but works in another one, given that apparently it is in the Swift standard library. Without this post I would probably have gone crazy.