Commit Graph
150 Commits
Author SHA1 Message Date
Karoy Lorentey 842f125c47 Invert dependencies to ContainersPreview, moving all container APIs there
- Move `InputSpan` into its own module, `SpanPreview`. Add dependencies to it.
- Invert dependencies to `ContainersPreview`, so that no production target imports it, but it now depends on its previous dependents.
- Move all generic APIs and conformances using `Producer`/`Drain`/`Container` to the `ContainersPreview` module.
- Remove `UnstableContainersPreview` conditions around `Iterable` APIs

In summary, importing `BasicContainers` and `DequeModule` continue to get us the basic definitions for `RigidArray`, `UniqueSet`, `RigidDeque` etc., without most of their unstable APIs. (With the exception of core APIs that require `InputSpan`.)

To get any API that uses an unstable protocol like `Container` or `Drain`, we’ll now need to import `ContainersPreview` in addition to the type-defining module.

This will provide a slightly less horrible migration path when (if) the container/producer protocol family gets adopted/adapted into the stdlib.
2026-08-25 18:29:58 -07:00
Anton Karpov c2b2092f94 Name the documented arguments the way the declarations name them
Twenty-five doc comments in the shipping modules name an argument that the
declaration below them does not have, so DocC has nothing to bind the
description to and drops it. Nothing warns about this.

Most of them are renames that the comment did not follow, and the file itself
usually holds the proof: RigidDeque.prepend says - maxCount while its own
Complexity line already says newItemCount, and append(copying:) has three
overloads where the oldest still takes newElements and the two newer ones take
items with the older one's wording.

Three entries name an argument that no longer exists at all and are removed
rather than renamed.
2026-08-13 16:29:06 +03:00
Alejandro Alonso d6c0fe063e Remove references to ManagedBuffer.capacity and use the given minCapacity
Fix errors

Update Deque._UnsafeHandle.swift
2026-08-12 14:09:05 -07:00
Karoy Lorentey 669eb09cea Use Iterable from the Standard Library, replacing the local definition 2026-07-27 13:32:46 -07:00
Karoy Lorentey 8380ca41da Merge pull request #682 from lorentey/container-updates
[ContainersPreview] Update Container protocols
2026-07-22 13:08:25 -07:00
Karoy Lorentey 232dc7f9ee Add second parameter to Container.makeBorrowingIterator(from:to:) 2026-07-21 15:21:45 -07:00
Karoy Lorentey e75f053e46 Update MutableContainer
- Add `nextMutableSpan(after:)` and `nextMutableSpan(after:maxCount:limitedBy)`, replacing `nextMutableSpan(after:maxCount:)` as the core access primitives
- Add `previousMutableSpan` default algorithms on bidirectional mutable containers
2026-07-20 15:44:35 -07:00
Karoy Lorentey ef0fba7f7f Resolve some implementation issues 2026-07-20 15:42:28 -07:00
Karoy Lorentey 95395ad9d2 Add BidirectionalContainer.spanBoundary(before:maxDistance:limitedBy:) and make it the core primitive 2026-07-20 11:51:43 -07:00
Karoy Lorentey e70b4df228 Introduce Container.nextSpan(after:maxCount:limitedBy:) and make it the core Container primitive 2026-07-18 14:14:13 -07:00
Karoy Lorentey a7f6b90c99 Make the limit optional in Container.nextSpan(after:limitedBy:). Review and update default implementations
- Make `nextSpan(after:limitedBy:)` the core iteration interface
- Review default algorithms and update them to use it, speeding them up
- Spin off `Span._nextSpan(after:maxCount)` and `Span._nextSpan(after:limitedBy:)` with copying lifetime semantics. This allows forwarding to these without having to override lifetimes.
2026-07-17 16:57:26 -07:00
Karoy Lorentey 99ac14d1fa previousSpan(before:maxCount:) ⟹ spanBoundary(before:maxDistance:)
This allows MutableContainers to support mutating iteration backwards without requiring a separate MutableBidirectionalContainer protocol.
2026-07-17 11:50:38 -07:00
Karoy Lorentey 62332dc40a Avoid borrow/mutate accessors before Swift 6.4 2026-07-07 16:52:32 -07:00
Karoy Lorentey b1cba02393 [DequeModule] Disable Equatable/Hashable conformance on pre-6.4 toolchains 2026-07-07 16:47:05 -07:00
Karoy Lorentey fbb8aa1e36 [DequeModule] UniqueDeque: Add isTriviallyIdentical(to:) 2026-07-07 16:42:51 -07:00
Karoy Lorentey 920bc2a81f [DequeModule] RigidDeque: Fix duplicate Equatable conformance 2026-07-07 15:21:26 -07:00
Karoy Lorentey ff695132ed Bump availability of Iterable_ and Container protocols to SwiftStdlib 6.4
This is preparing for switching over to the stdlib’s definition of `protocol Iterable`, assuming it will land with macOS 27/iOS 27 etc availability; `Container` is refining `Iterable`, so it needs matching availability.

If `Iterable` won’t ship in Swift 6.4, then we’ll need to bump this again.
2026-07-07 14:22:45 -07:00
Karoy Lorentey a80c9d1257 Container: Add makeBorrowingIterator(from:) and currentIndex(of:) requirements 2026-07-07 14:21:54 -07:00
Karoy Lorentey d0b4c4c215 IterableIterator_ → BorrowingIterator_ 2026-07-07 14:21:53 -07:00
Karoy Lorentey bb0dc189ef maximumCount → maxCount
While we’re here, adjust `RigidSet.insert(maximumCount:initializingWith:)` and similar APIs to be consistent with RangeReplaceableContainer’s methods.
2026-07-07 14:21:53 -07:00
Karoy Lorentey 72c0dd258d IterableIteratorProtocol_ → BorrowingIteratorProtocol_ 2026-07-07 14:20:26 -07:00
Karoy Lorentey 3ba8d70ec3 Review and update container protocols and conformances
- @inlinable → @_alwaysEmitIntoClient for now, to avoid temporary ABI issues
- Review RangeReplaceableContainer algorithms; add missing ones:
    - New requirements: `removeFirst()`, `removeFirst(_:)`, `_customRemoveLast()`, `_customRemoveLast(_:) (with default implementations)
    - `func removeAll()`
    - `func removeLast()`, `func removeLast(_:)`, `func popLast()` when self is also bidirectional
- Review RigidArray, UniqueArray algorithms; remove ones needlessly duplicating functionality already provided by RRC. Try not to break source compatibility.
2026-07-07 14:18:09 -07:00
wjdtjq6 62a08e503e docs: fix typos in doc comments and DocC article 2026-07-02 21:17:11 +09:00
Karoy Lorentey e8b09ade25 Add subscript requirements to [Mutable]Container with borrow/mutate accessors 2026-06-22 20:10:22 -07:00
Karoy Lorentey 12b1cf8020 [ContainersPreview] Make Drain refine CountedProducer
This lets us avoid having to pass an explicit count when using a drain to populate a container.
2026-06-18 13:22:16 -07:00
Karoy Lorentey 1f5d0ab343 [BasicContainers, DequeModule] Resolve warnings in 6.4 2026-06-18 13:21:42 -07:00
Karoy Lorentey 73ec3d3416 [BasicContainers, DequeModule] Clean up Equatable/Hashable conformances
Make sure all types conditionally conform to Equatable/Hashable, even if their contents happen to be noncopyable.
2026-06-18 12:56:23 -07:00
Karoy Lorentey 3d68fc1107 Clean up the UniqueBox/Ref/MutableRef situation
- UniqueBox is public API, so we cannot remove it in favor of the stdlib’s
- Remove Ref and MutableRef. Keep an internal _MutableRef to work around stdlib limitations.
2026-06-17 18:29:41 -07:00
Karoy Lorentey bced34defa Review error handling 2026-06-17 18:24:03 -07:00
Karoy Lorentey 85cdb77d25 Fix build issues 2026-06-17 16:17:36 -07:00
Nate Cook dca015d7e8 Align Iterable with proposal
Adds throwing and ~Escapable elements
2026-06-17 14:27:29 -07:00
Nate Cook 4bda43f4a9 Renaming BorrowingSequence_ to Iterable_ 2026-06-17 14:27:29 -07:00
Karoy Lorentey c38e47d03e [BasicContainers, DequeModule] Avoid using deprecated API 2026-05-07 16:17:20 -07:00
Karoy Lorentey 16d6b8e1fe [ContainersPreview] Inout ⟹ MutableRef 2026-05-06 18:28:07 -07:00
Karoy Lorentey a6fd64697a [ContainersPreview] Borrow ⟹ Ref
Also update the type’s public API surface to reflect SE-0519, leaving deprecated aliases for the old names.
2026-05-06 18:00:13 -07:00
Franz Busch 3c373b900c Use the defines from traits directly
Package traits already pass defines with their trait name when building. Instead of adding our own conditional defines based on the traits we can use the trait provided defines directly. I observed that various tooling behaves better with the trait provided defines.
2026-05-06 07:41:02 -07:00
Karoy Lorentey 022795168a [BasicContainers] Enable APIs scheduled to ship in 1.5.0
- `RigidArray.nextMutableSpan(after:maximumCount:)`
- `UniqueArray.nextMutableSpan(after:maximumCount:)`
- `RigidDeque.nextMutableSpan(after:maximumCount:)`
- `UniqueDeque.nextMutableSpan(after:maximumCount:)`
- `UniqueArray.init(minimumCapacity:)` (replacing `.init(capacity:)`)
- `UniqueDeque.init(minimumCapacity:)` (replacing `.init(capacity:)`)
- `RigidDeque.index(before:)`
- `UniqueDeque.index(before:)`
- `RigidDeque.formIndex(before:)`
- `UniqueDeque.formIndex(before:)`
2026-05-05 16:01:31 -07:00
Karoy Lorentey cd0ca78dbd [DequeModule] Assorted UniqueDeque doc string fixes 2026-04-27 18:10:26 -07:00
Karoy Lorentey 4225f78a2b [DequeModule]: UniqueDeque.insert(addingCount:at:initializingWith:): Add empty shortcut 2026-04-27 18:01:24 -07:00
Karoy Lorentey c068f8ccb7 [DequeModule] UniqueDeque replacements with Collections: Verify that the source’s count matches its contents 2026-04-27 18:01:24 -07:00
Karoy Lorentey 2c86775a6b [DequeModule] UniqueDeque.replace(removing:addingCount:initializingWith:): Fix sizing issue 2026-04-27 18:01:24 -07:00
Karoy Lorentey 30f28dcdcb [DequeModule] RigidDeque.consume(_:consumingWith:): Style nit: consume span explicitly 2026-04-27 18:01:24 -07:00
Karoy Lorentey f5661c674a [DequeModule] insert(addingCount:initializingWith:): Add shortcut for zero elements 2026-04-27 18:01:23 -07:00
Karoy Lorentey 285016b285 [DequeModule] RigidDeque replacements with Collections: Verify that the source’s count matches its contents 2026-04-27 18:01:23 -07:00
Karoy Lorentey 1d5418fb68 [DequeModule] RigidDeque.prepend(addingCount:initializingWith:): Add shortcut for zero elements
This was already present in the append variant; there is no reason not to do the same here.
2026-04-27 18:01:23 -07:00
Karoy Lorentey 5342399a18 [DequeModule] Fix small issues in doc strings 2026-04-27 18:01:23 -07:00
Karoy Lorentey 0be6f43972 [DequeModule] RigidDeque.nextMutableSpan(after:maximumCount:): Fix missing argument validation 2026-04-27 17:25:50 -07:00
Karoy Lorentey 654d57533f [DequeModule] RigidDeque.consume(_:consumingWith:): Close resulting gap before returning 2026-04-27 17:18:05 -07:00
Karoy Lorentey 35b7d8fba4 Fix lifetime requirements rigidly enforced in the latest nightlies 2026-04-03 17:01:36 -07:00
Karoy Lorentey 597b7a7dd2 Revert most of the availability constraints from 419e2f and 4c0482 🎉 2026-03-27 11:25:43 -07:00