Skip to content

[ContainersPreview] Add DrainableContainer above RangeReplaceableContainer - #707

Open
lorentey wants to merge 2 commits into
apple:mainfrom
lorentey:container-updates
Open

[ContainersPreview] Add DrainableContainer above RangeReplaceableContainer#707
lorentey wants to merge 2 commits into
apple:mainfrom
lorentey:container-updates

Conversation

@lorentey

Copy link
Copy Markdown
Member

We have types that can usefully conform to DrainableContainer but not the full RangeReplaceableContainer; OrderedSet is one obvious example.

This reminded me that we don't have a removeAll(where:) method yet; we'll need one as well as an in-place consuming variant. Ideally these would be implemented by default using SubrangeConsumer, but that would require a Drain that allows partial consumption -- which would be a large complicating factor. 🤔 The easy choice is to define a higher-order, InputSpan-based consume requirement that preserves whatever elements the client leaves in the span, and then have the predicate-based methods forward to that. However, I'm hoping we can do better.

Checklist

  • I've read the Contribution Guidelines
  • My contributions are licensed under the Swift license.
  • I've followed the coding style of the rest of the project.
  • I've added tests covering all new code paths my change adds to the project (if appropriate).
  • I've added benchmarks covering new functionality (if appropriate).
  • I've verified that my change does not break any existing tests or introduce unexplained benchmark regressions.
  • I've updated the documentation if necessary.

…eReplaceableContainer into a new DrainableContainer protocol

We have types that can usefully conform to `DrainableContainer` but not the full `RangeReplaceableContainer`; `OrderedSet` is one obvious example.
@lorentey lorentey added this to the 1.7.0 milestone Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant