Commit Graph
116 Commits
Author SHA1 Message Date
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 51c9e4ead8 Fix IterableIteratorProtocol.map; add map2 and map3 with different throwing behavior 2026-06-17 18:24:03 -07:00
Karoy Lorentey 7c853751c6 Add IterableIteratorProtocol.mapError 2026-06-17 18:24:03 -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
Karoy Lorentey 816b887369 Update CMake and Xcode build configurations 2026-06-17 14:40:07 -07:00
Nate Cook c039a18a0e Switch to using stdlib Ref and UniqueBox 2026-06-17 14:27:29 -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 e31c04143e Update CMake & Xcode build configurations 2026-06-05 18:45:56 -07:00
Guoye Zhang 8cacd3c125 Add missing availability to Borrow 2026-05-18 17:50:20 -07:00
Franz Busch f674e13c3d Guard UniqueBox.borrow correctly
Correctly guard the `borrow` method behind the compiler version
2026-05-11 14:43:54 +02:00
Karoy Lorentey 16d6b8e1fe [ContainersPreview] Inout ⟹ MutableRef 2026-05-06 18:28:07 -07:00
Karoy Lorentey 1fd366764d [ContainersPreview] Ref: Fix fallback implementation; make sure we have deprecated aliases for old names 2026-05-06 18:00:13 -07:00
Karoy Lorentey 18c58bcca4 [ContainersPreview] Ref: Disable Builtin.Borrow for now 2026-05-06 18:00:13 -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 3a55ce888c [ContainersPreview] UniqueBox.value: Avoid using borrow/mutate on old compilers
These (and `@_unsafeSelfDependentResult`) are only usable on 6.4 snapshots. As 6.4 hasn’t shipped yet, we need to also make these conditional on the UnstableContainersPreview trait.
2026-05-05 17:31:09 -07:00
Karoy Lorentey 146056a641 [ContainersPreview] Box ⟹ UniqueBox
Also update the type’s public API surface to reflect SE-0517, leaving deprecated aliases for the old names.
2026-05-05 17:31:05 -07:00
Karoy Lorentey dd6dd8a445 [ContainersPreview] Clean up some notes 2026-05-01 15:13:45 -07:00
Karoy Lorentey f652543a50 [ContainersPreview] Producer.ProducerError ⟹ Producer.Failure
Reserving a unique name for Producer’s failure type seems unwise, especially if we end up Producer refining a throwing BorrowingSequence protocol.
2026-04-30 13:31:28 -07:00
Karoy Lorentey 1c95e19aeb [ContainersPreview] Don’t require Container.Index to conform to Comparable
This slows down the default implementations of `distance(from:to:)` and `index(_:offsetBy:limitedBy:)`, but it allows linked lists to conform to `Container`. The trade off seems fair.

While we’re here, flesh out the `BidirectionalContainer` refinements a little, and add `Container.isEmpty` and `._custom[Last]IndexOfEquatableElement(_:)`.

This code is still untested.
2026-04-16 18:04:37 -07:00
Karoy Lorentey 35b7d8fba4 Fix lifetime requirements rigidly enforced in the latest nightlies 2026-04-03 17:01:36 -07:00
Karoy Lorentey 495d96d27d [ContainersPreview] Better illuminate the nextSpan problem on ContainerIterator 2026-04-03 09:01:48 -07:00
Karoy Lorentey 75b0309e12 Producer.skip(upTo:) → .skip(by:)
This is to align naming with BorrowingIteratorProtocol. The signatures are still different, as Producers may throw.
2026-03-27 11:52:05 -07:00
Karoy Lorentey f83e9b6538 Rename Collection.underestimatedCount_ 2026-03-27 11:47:00 -07:00
Karoy Lorentey 597b7a7dd2 Revert most of the availability constraints from 419e2f and 4c0482 🎉 2026-03-27 11:25:43 -07:00
Nate Cook efdc1bbd96 Remove BorrowingSequence experimental feature flag
This prevents accidental usage of the experimental stdlib feature,
where the library's implementation is intended instead.
2026-03-27 10:56:44 -05:00
Nate Cook a99a015934 Disambiguate ContainersPreview and stdlib
Adds trailing underscores to the BorrowingSequence protocols and
requirements, in order to allow both parallel conformances and
the ability to evolve the requirements in this package.
2026-03-27 07:41:32 -05:00
Karoy Lorentey 4c04822689 [ContainersPreview] Exhibit B in the case against prototyping things in the stdlib 😳 2026-03-26 18:13:22 -07:00
Karoy Lorentey d2d3b917ca [BasicContainers, ContainersPreview, DequeModule] More SuppressedAssociatedTypesWithDefaults fixups 2026-03-26 18:12:41 -07:00
Karoy Lorentey 419e2f7df2 [ContainersPreview] Exhibit A in the case against prototyping things in the stdlib 😞 2026-03-26 17:14:45 -07:00
Karoy Lorentey 3e380cb358 [ContainersPreview] Work around compiler crash 2026-03-26 17:14:44 -07:00
Karoy Lorentey fa80d7c0d3 [ContainersPreview] Work around name lookup anomaly 2026-03-26 16:17:53 -07:00
Karoy Lorentey a1acf5003b [ContainersPreview] Make ConsumingMapProducer unconditionally nonescapable 2026-03-26 16:08:49 -07:00
Karoy Lorentey 13c5d9b480 [ContainersPreview] Avoid weird compiler(?) issue(?) with ConsumingFilterProducer’s conditional conformance to Escapable 2026-03-26 16:06:04 -07:00
Karoy Lorentey eb708a9ba5 [ContainersPreview] Audit some protocol extensions for SuppressedAssociatedTypesWithDefaults 2026-03-26 16:05:07 -07:00
Karoy Lorentey 70a25f1f69 [ContainersPreview] Bump required toolchain to 6.4 for new protocols 2026-03-26 14:51:08 -07:00
Nate Cook 2eac7ce64d Add tests for BorrowingSequence
With just enough algorithms (reduce, elementsEqual) to test.
2026-03-26 14:25:01 -05:00
Nate Cook a2cf230400 Align BorrowingSequence etc with proposal
This updates the ContainersPreview module to use the same
API as the proposed BorrowingSequence protocol and its supporting
types. In particular, instead of using Span as the iterator for
itself and other contiguously-stored types, this introduces
SpanIterator.
2026-03-26 14:25:01 -05:00
Karoy Lorentey 8f88cce7c7 [BasicContainers, ContainersPreview] Make sure package traits “work” on 6.2 toolchains
“Work” in this case means that they can be enabled without breaking the build — not necessarily that all features are available.

Swift 6.2 is highly prone to runtime crashes in `swift_getTypeByMangledName` in generic code that uses ownership features. Swift 6.3 will resolve that.
2026-03-17 15:38:34 -07:00
Karoy Lorentey 3dc65340f3 [ContainersPreview] Fix support for Swift 6.2 2026-03-17 13:45:15 -07:00
Karoy Lorentey 2364daa6bf [ContainersPreview] Update CMake & Xcode build files 2026-03-17 13:32:12 -07:00
Karoy Lorentey 29148932ec [ContainersPreview] Add a Producer.collect(into:) that takes a RangeReplaceableContainer
This is getting into dangerous territory, as RRC allows fixed-capacity conformers, where appending a producer must be done extremely carefully. We should be using bulk append operations, but never ask the container to reserve any more slots than the producer is able to actually generate. (When the fixed-capacity RRC was carefully sized to precisely fit the generator’s contents, asking it to provide space for even a single item more would lead to a runtime trap.)

Additionally, the algorithm should work (and be reasonably efficient) even if the RRC happens to be a dynamically sizing container type.

It would be nice if we had a Producer protocol flavor with an exact count; failing that, we can still do this with a bit of acrobatics, as implemented here.  (The `DynamicContainer.append(from:)` algorithm was already implemented this way in a previous commit, with an eye towards this case.)
2026-03-17 13:32:11 -07:00
Karoy Lorentey 2e277a949b [ContainersPreview] Add a BorrowingIteratorProtocol.copy() algorithm to turn borrowing iterators into producers 2026-03-17 13:32:11 -07:00
Karoy Lorentey d974987957 [ContainersPreview] DynamicContainer’s Producer-taking init/append methods should consume their input
(Because they are running it to completion.)
2026-03-17 13:16:43 -07:00
Karoy Lorentey 7e103afbb6 [ContainersPreview] Oops, fix constraints on conformances of BorrowingMapProducer and BorrowingFilter 2026-03-17 13:15:03 -07:00
Karoy Lorentey 6bbed0e1e2 [ContainersPreview] Conform [Unique,Rigid]Array and [Unique,Rigid]Deque to container protocols 2026-03-17 13:13:42 -07:00
Karoy Lorentey 121462fe19 [ContainersPreview] Add some implementations of .filter 2026-03-16 15:04:30 -07:00
Karoy Lorentey ea00086c7a [ContainersPreview] Update CMake/Xcode build configurations 2026-03-13 10:41:06 -07:00