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 49413a0

Browse files
matthiaskrgrgitbot
authored and
gitbot
committedMar 11, 2025
Rollup merge of rust-lang#135073 - joshtriplett:bstr, r=BurntSushi
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 65064c6 + c07ef0c commit 49413a0

File tree

8 files changed

+1363
-0
lines changed

8 files changed

+1363
-0
lines changed
 

‎alloc/src/bstr.rs

+702
Large diffs are not rendered by default.

‎alloc/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@
102102
#![feature(async_fn_traits)]
103103
#![feature(async_iterator)]
104104
#![feature(box_uninit_write)]
105+
#![feature(bstr)]
106+
#![feature(bstr_internals)]
105107
#![feature(clone_to_uninit)]
106108
#![feature(coerce_unsized)]
107109
#![feature(const_eval_select)]
@@ -228,6 +230,8 @@ mod boxed {
228230
pub use std::boxed::Box;
229231
}
230232
pub mod borrow;
233+
#[unstable(feature = "bstr", issue = "134915")]
234+
pub mod bstr;
231235
pub mod collections;
232236
#[cfg(all(not(no_rc), not(no_sync), not(no_global_oom_handling)))]
233237
pub mod ffi;
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.