Skip to content

[SE-0485, 6.2] OutputSpan and OutputRawSpan #83000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: release/6.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions Runtimes/Core/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ add_library(swiftCore
Span/RawSpan.swift
Span/MutableSpan.swift
Span/MutableRawSpan.swift
Span/OutputSpan.swift
Span/OutputRawSpan.swift
StaticString.swift
StaticPrint.swift
Stride.swift
Expand Down
2 changes: 2 additions & 0 deletions stdlib/public/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ split_embedded_sources(
EMBEDDED Sort.swift
EMBEDDED Span/MutableRawSpan.swift
EMBEDDED Span/MutableSpan.swift
EMBEDDED Span/OutputRawSpan.swift
EMBEDDED Span/OutputSpan.swift
EMBEDDED Span/RawSpan.swift
EMBEDDED Span/Span.swift
EMBEDDED StaticString.swift
Expand Down
2 changes: 2 additions & 0 deletions stdlib/public/core/GroupInfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@
"Span": [
"MutableRawSpan.swift",
"MutableSpan.swift",
"OutputRawSpan.swift",
"OutputSpan.swift",
"RawSpan.swift",
"Span.swift"
],
Expand Down
19 changes: 19 additions & 0 deletions stdlib/public/core/InlineArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,25 @@ extension InlineArray where Element: ~Copyable {
}
#else
fatalError()
#endif
}

@available(SwiftStdlib 6.2, *)
@_alwaysEmitIntoClient
public init<E: Error>(
initializingWith initializer: (inout OutputSpan<Element>) throws(E) -> Void
) throws(E) {
#if $BuiltinEmplaceTypedThrows
_storage = try Builtin.emplace { (rawPtr) throws(E) -> () in
let buffer = unsafe Self._initializationBuffer(start: rawPtr)
_internalInvariant(Self.count == buffer.count)
var output = unsafe OutputSpan(buffer: buffer, initializedCount: 0)
try initializer(&output)
let initialized = unsafe output.finalize(for: buffer)
_precondition(count == initialized, "InlineArray initialization underflow")
}
#else
fatalError()
#endif
}
}
Expand Down
Loading