Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 907feae

Browse files
committedJan 7, 2025
Auto merge of rust-lang#135073 - joshtriplett:bstr, r=<try>
Implement `ByteStr` and `ByteString` types Approved ACP: rust-lang/libs-team#502 Tracking issue: rust-lang#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`, and `Borrow`, when those would be the second implementation for a type (counting the `T` impl), to avoid potential inference failures. We can attempt to add more impls 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`
2 parents fb546ee + 75a8d0d commit 907feae

17 files changed

+1424
-24
lines changed
 

‎library/alloc/src/bstr.rs

+710
Large diffs are not rendered by default.

‎library/alloc/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@
103103
#![feature(async_fn_traits)]
104104
#![feature(async_iterator)]
105105
#![feature(box_uninit_write)]
106+
#![feature(bstr)]
107+
#![feature(bstr_internals)]
106108
#![feature(clone_to_uninit)]
107109
#![feature(coerce_unsized)]
108110
#![feature(const_eval_select)]
@@ -227,6 +229,8 @@ mod boxed {
227229
pub use std::boxed::Box;
228230
}
229231
pub mod borrow;
232+
#[unstable(feature = "bstr", issue = "134915")]
233+
pub mod bstr;
230234
pub mod collections;
231235
#[cfg(all(not(no_rc), not(no_sync), not(no_global_oom_handling)))]
232236
pub mod ffi;
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.