Skip to content

Implement ByteStr and ByteString types - #135073

Merged
bors merged 8 commits into
rust-lang:masterfrom
joshtriplett:bstr
Jan 24, 2025
Merged

Implement ByteStr and ByteString types#135073
bors merged 8 commits into
rust-lang:masterfrom
joshtriplett:bstr

Conversation

@joshtriplett

@joshtriplett joshtriplett commented Jan 3, 2025

Copy link
Copy Markdown
Member

Approved ACP: rust-lang/libs-team#502
Tracking issue: #134915

These types represent human-readable strings that are conventionally,
but not always, UTF-8. The Debug impl prints non-UTF-8 bytes using
escape sequences, and the Display impl uses the Unicode replacement
character.

This is a minimal implementation of these types and associated trait
impls. It does not add any helper methods to other types such as [u8]
or Vec<u8>.

I've omitted a few implementations of AsRef, AsMut, Borrow,
From, and PartialOrd, when those would be the second implementation
for a type (counting the T impl) or otherwise may cause inference
failures. These impls are important, but we can attempt to add them
later in standalone commits, and run them through crater.

In addition to the bstr feature, I've added a bstr_internals feature
for APIs provided by core for use by alloc but not currently
intended for stabilization.

This API and its implementation are based heavily on the bstr crate
by Andrew Gallant (@BurntSushi).

r? @BurntSushi

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api [DEPRECATED; DO NOT USE]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants