Skip to content

Add ByteBuffer.readableBytesUInt8Span#3458

Merged
Lukasa merged 2 commits intoapple:mainfrom
adam-fowler:readable-bytes-span-2
Dec 5, 2025
Merged

Add ByteBuffer.readableBytesUInt8Span#3458
Lukasa merged 2 commits intoapple:mainfrom
adam-fowler:readable-bytes-span-2

Conversation

@adam-fowler
Copy link
Copy Markdown
Contributor

Add ByteBuffer.readableBytesUInt8Span

Motivation:

Provide access to readableBytes as a Span

Modifications:

Added computed property ByteBuffer.readableBytesUInt8Span. I also attempted to add ByteBuffer.mutableReadableBytesUInt8Span but due to an apparently faulty exclusivity issue I couldn't get this to work. See swiftlang/swift#81218.

Result:

You can access the readable bytes of a ByteBuffer as a Span

}

@Test
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, *)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did these availabilities come from?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Span.bytes requires macOS 26

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it's probably nicer to just copy-paste the implementation from the raw span side and get the lower availability.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Lukasa Lukasa added the 🆕 semver/minor Adds new public API. label Dec 5, 2025
@Lukasa
Copy link
Copy Markdown
Contributor

Lukasa commented Dec 5, 2025

Thanks Adam!

@Lukasa Lukasa merged commit 888f4af into apple:main Dec 5, 2025
57 checks passed
@adam-fowler adam-fowler deleted the readable-bytes-span-2 branch December 5, 2025 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants