Commit Graph
65 Commits
Author SHA1 Message Date
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
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 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 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 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
Karoy Lorentey bf18a48983 [ContainersPreview] Spin off Producer.collect algorithms into a separate file for easy lookups 2026-03-13 10:41:04 -07:00
Karoy Lorentey c4760ec21a [ContainersPreview] Flesh out container protocols a little more; add algorithms
(This is all untested, unproven code)
2026-03-13 10:30:49 -07:00
Karoy Lorentey 6acfa78c6c [ContainersPreview] Quick updates to Container 2026-03-13 09:14:30 -07:00
Karoy Lorentey cde6e86f4f [ContainersPreview] Underscore elementsEqual for now, to avoid ambiguity with the Sequence method 2026-03-13 09:14:15 -07:00
Karoy Lorentey 41beccbd44 Merge pull request #598 from lorentey/remove-BorrowingSequence.first
[ContainersPreview] Remove BorrowingSequence.first
2026-03-09 16:40:18 -07:00
Karoy Lorentey 3826fe76a8 [ContainersPreview] Rename Producer.generateNext() to next()
This better highlights the symmetry between it and the classic method on `IteratorProtocol`, and is also a nice usability win.
2026-03-09 16:22:24 -07:00
Karoy Lorentey 3b10b992bc [ContainersPreview] Remove BorrowingSequence.first
This property is unnecessary; it was just demonstrating an old problem. It clashes with the classic `Collection.first`, and that renders invocations of that ambiguous in code that uses Collection types that also have a BorrowingSequence conformance.
2026-03-09 16:11:56 -07:00
Karoy Lorentey 1c69635852 Add SPDX-License-Identifier tags 2026-03-05 19:39:24 -08:00
Karoy Lorentey d9b09ecde8 Update copyright dates 2026-03-05 19:39:20 -08:00
Karoy Lorentey 214d75cb73 BorrowingSequence: estimatedCount ⟹ underestimatedCount
EstimatedCount is largely pointless. Knowing the exact count does enable a fast negative path for `elementsEqual`, but we can otherwise make do with just the (much simpler to understand/deal with) `underestimatedCount` that already exists on `Sequence`.
2026-03-05 15:33:27 -08:00
Karoy Lorentey b7545b990b [BasicContainers] Add bulk insertions to hashed set types 2026-02-27 13:36:37 -08:00
Karoy Lorentey 4452b1c960 [ContainersPreview] Mark ProducerError as a primary associated type of Producer 2026-02-24 16:41:31 -08:00