Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c2944fb
WIP OutputMultispan + basic adoption in RigidArray and UniqueArray
Catfish-Man Feb 24, 2026
146c2cd
Update Sources/ContainersPreview/Types/OutputMultispan.swift
Catfish-Man Feb 24, 2026
a9fc724
WIP InputMultispan
Catfish-Man Feb 26, 2026
b7fe7ec
Fix a bunch of bugs in OutputMultispan
Catfish-Man Feb 26, 2026
fc4adec
Add InputMultispan to the project file
Catfish-Man Feb 26, 2026
03a4083
Build fixes
Catfish-Man Feb 26, 2026
97322b2
Many more fixes
Catfish-Man Feb 26, 2026
b8992db
Review cleanup
Catfish-Man Feb 26, 2026
e183879
Add new files to cmake
Catfish-Man Feb 26, 2026
81b2d37
Yet more fixes
Catfish-Man Feb 26, 2026
e97fd9a
Merge branch 'main' into leeloo-dallas-multispan
Catfish-Man Mar 3, 2026
5ec9c1a
Fix problems exposed by a newer swiftc
Catfish-Man Mar 3, 2026
a0512f4
Preliminary tests for OutputMultispan. Note: several of them fail cur…
Catfish-Man Mar 3, 2026
8a0506f
OutputMultispan tests pass now!
Catfish-Man Mar 5, 2026
df666c5
InputMultispan test fixes
Catfish-Man Mar 10, 2026
31c8c74
Add tests to project, oops
Catfish-Man Mar 11, 2026
5ad3a47
Add inline storage support, but don't adopt it yet
Catfish-Man Mar 13, 2026
c422c75
Adopt inline storage and deduplicate some logic
Catfish-Man Mar 13, 2026
d1dbe97
Minor cleanup and inlining
Catfish-Man Mar 13, 2026
f61fabb
Address optimization TODOs
Catfish-Man Mar 13, 2026
db9f5f9
Review fixes
Catfish-Man Mar 14, 2026
e6a68b2
More review fixes
Catfish-Man Mar 14, 2026
6350725
Remove stray logging in the tests
Catfish-Man Mar 18, 2026
0b76d6f
Merge remote-tracking branch 'github/main' into leeloo-dallas-multispan
Catfish-Man Mar 18, 2026
a48b43a
Update license headers for new files
Catfish-Man Mar 18, 2026
0d2d90f
Missed one
Catfish-Man Mar 18, 2026
0e7016f
Adjust things to make the package buildable
lorentey Mar 28, 2026
31aeffe
Switch from type punning to an enum
Catfish-Man Mar 30, 2026
6f73381
Fix compile errors and switch to @lifetime()
Catfish-Man Mar 30, 2026
64a5117
Switch back to _lifetime, I had misunderstood
Catfish-Man Mar 30, 2026
3599608
Merge branch 'main' into leeloo-dallas-multispan
Catfish-Man Mar 31, 2026
7e21887
Fix build failures
Catfish-Man Mar 31, 2026
478d3ec
Fix test build failures
Catfish-Man Apr 1, 2026
6e45911
Merge remote-tracking branch 'github/main' into leeloo-dallas-multispan
Catfish-Man Apr 3, 2026
dd2b476
Resolve ambiguous methods
Catfish-Man Apr 3, 2026
0006013
Merge remote-tracking branch 'origin/main' into leeloo-dallas-multispan
lorentey Apr 4, 2026
2e1f550
Oops, fix RawCollider conflict
lorentey Apr 7, 2026
b387eba
{Input,Output}Multispan: Fix bug in index validation
lorentey Apr 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ set(collections_swift_flags
"-enable-upcoming-feature MemberImportVisibility"
"-enable-experimental-feature BuiltinModule"
"-enable-experimental-feature Lifetimes"
"-enable-experimental-feature LifetimeDependence"
"-enable-experimental-feature InoutLifetimeDependence"
)
foreach(flag ${collections_swift_flags})
Expand Down
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ let extraSettings: [SwiftSetting] = [
// .strictMemorySafety(),
.enableExperimentalFeature("BuiltinModule"),
.enableExperimentalFeature("Lifetimes"),
.enableExperimentalFeature("LifetimeDependence"),
.enableExperimentalFeature("InoutLifetimeDependence"),
.enableExperimentalFeature("SuppressedAssociatedTypes"),
.enableExperimentalFeature("AddressableParameters"),
Expand Down
3 changes: 3 additions & 0 deletions Sources/ContainersPreview/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ endif()

target_sources(${module_name} PRIVATE
"Extensions/OutputSpan+Extras.swift"
"Extensions/OutputMultispan+Extras.swift"
"Extensions/TemporaryAllocation.swift"
"Protocols/BorrowingIteratorProtocol.swift"
"Protocols/BorrowingSequence.swift"
Expand All @@ -37,5 +38,7 @@ target_sources(${module_name} PRIVATE
"Types/Box.swift"
"Types/Inout.swift"
"Types/InputSpan.swift"
"Types/InputMultispan.swift"
"Types/Shared.swift"
"Types/OutputMultispan.swift"
)
71 changes: 71 additions & 0 deletions Sources/ContainersPreview/Extensions/OutputMultispan+Extras.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Collections open source project
//
// Copyright (c) 2024 - 2026 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
//
//===----------------------------------------------------------------------===//

#if compiler(>=6.2) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW

#if !COLLECTIONS_SINGLE_MODULE
import InternalCollectionsUtilities
#endif

@available(SwiftStdlib 5.0, *)
extension RigidArray where Element: ~Copyable {
@_alwaysEmitIntoClient
public mutating func append<E: Error>(
addingCount newItemCount: Int,
initializingWith initializer: @escaping (inout OutputMultispan<Element>) async throws(E) -> Void
) async throws(E) {
precondition(newItemCount >= 0, "Cannot add a negative number of items")
precondition(freeCapacity >= newItemCount, "RigidArray capacity overflow")
let buffer = _freeSpace._extracting(first: newItemCount)
var span = OutputSpan(buffer: buffer, initializedCount: 0)
defer {
_count &+= span.finalize(for: buffer)
span = OutputSpan()
}
var multiSpan = OutputMultispan<Element>()
multiSpan._appendSpan(&span)
return try await initializer(&multiSpan)
}

@inlinable
public init<E: Error>(
capacity: Int,
initializingWith body: @escaping (inout OutputMultispan<Element>) throws(E) -> Void
Comment thread
Catfish-Man marked this conversation as resolved.
Outdated
) async throws(E) {
self.init(capacity: capacity)
try await append(addingCount: capacity, initializingWith: body)
}
}

@available(SwiftStdlib 5.0, *)
extension UniqueArray where Element: ~Copyable {
@_alwaysEmitIntoClient
public mutating func append<E: Error>(
addingCount newItemCount: Int,
initializingWith initializer: @escaping (inout OutputMultispan<Element>) async throws(E) -> Void
) async throws(E) {
_ensureFreeCapacity(newItemCount)
return try await _storage.append(
addingCount: newItemCount,
initializingWith: initializer)
}

@inlinable
public init<E: Error>(
capacity: Int,
initializingWith body: @escaping (inout OutputMultispan<Element>) throws(E) -> Void
) async throws(E) {
self.init(capacity: capacity)
try await append(addingCount: capacity, initializingWith: body)
}
}

#endif
Loading