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 87bb396

Browse files
committedJan 3, 2025
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).
1 parent c156614 commit 87bb396

File tree

9 files changed

+1331
-3
lines changed

9 files changed

+1331
-3
lines changed
 

‎library/alloc/src/bstr.rs

+690
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)]
@@ -226,6 +228,8 @@ mod boxed {
226228
pub use std::boxed::Box;
227229
}
228230
pub mod borrow;
231+
#[unstable(feature = "bstr", issue = "134915")]
232+
pub mod bstr;
229233
pub mod collections;
230234
#[cfg(all(not(no_rc), not(no_sync), not(no_global_oom_handling)))]
231235
pub mod ffi;
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.