It would take too much effort to try to mitigate stdlib differences.
Fix low-hanging warnings, but turn off `.strictMemorySafety` on older toolchains by splitting the package manifest.
- 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.
The `_trim(first:)` and `_trim(last:)` helpers reassign `self` to the
remaining slice and then build the trimmed result from `self`'s now-updated
`baseAddress`/`count`, so they hand back a region that points into the wrong
place in the buffer.
`UnsafeMutableBufferPointer._trim(first:)` had this exact bug fixed earlier (it
captures `oldStart` before the reassignment), but three sibling helpers were
left untouched:
* `UnsafeBufferPointer._trim(first:)` reads `baseAddress` after advancing
`self`, so the returned prefix starts at the remainder instead of at the
original head.
* `UnsafeBufferPointer._trim(last:)` and
`UnsafeMutableBufferPointer._trim(last:)` recompute `count &- cut` after
shrinking `self`, so the returned suffix starts `cut` elements too early.
For a five-element buffer, `_trim(first: 2)` returned the bytes of `[30, 40]`
rather than `[10, 20]`, and `_trim(last: 2)` returned `[20, 30]` rather than
`[40, 50]`; trimming more than the count walked off the end of the buffer.
Capture the original start (and, for the suffix case, the post-trim count)
before mutating `self`, matching the already-correct `_trim(first:)` on the
mutable buffer. Adds direct tests covering both overloads on both buffer types.
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.
After reassigning self on line 160, baseAddress on line 161 resolves to the new self's baseAddress (oldStart + cut) instead of the original start. This causes the returned buffer to point past the actual elements into uninitialized memory. Use the captured oldStart instead.
This is currently conditional on the UnstableContainersPreview trait. (Swift 6.4 has not shipped yet, so we cannot unconditionally enable this without risking breakage.)
- Fix issues with the main package no longer exposing internal helper functions
- Move Rust benchmarks behind an EnableRustBenchmarks trait
- Allow traits to be enabled in `Utils/run-benchmarks.sh` through the BENCHMARK_TRAITS environment variable.
- Adopt and embrace Drain and Producer to simplify moving data in and out of deques.
- Fully generalized core range replacement primitive using higher-order functions based around InputSpan and OutputSpan