Repository navigation
Open
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
Feature gate: #![feature(bstr)]
This is a tracking issue for the ByteStr/ByteString types, which represent human-readable strings that are usually, but not always, UTF-8. Unlike &str/String, these types permit non-UTF-8 contents, making them suitable for user input, non-native filenames (as Path only supports native filenames), and other applications that need to round-trip whatever data the user provides.
This was approved in ACP rust-lang/libs-team#502 .
Public API
// In core::bstr
#[repr(transparent)]
pub struct ByteStr(pub [u8]);
impl ByteStr {
pub fn new<B: ?Sized + AsRef<[u8]>>(bytes: &B) -> &Self { ... }
}
impl Debug for ByteStr { ... }
impl Display for ByteStr { ... }
impl Deref for ByteStr { type Target = [u8]; ... }
impl DerefMut for ByteStr { ... }
// Other trait impls from bstr, including From impls
// In alloc::bstr
#[repr(transparent)]
pub struct ByteString(pub Vec<u8>);
impl Debug for ByteString { ... }
impl Display for ByteString { ... }
impl Deref for ByteString { type Target = Vec<u8>; ... }
impl DerefMut for ByteString { ... }
// Other trait impls from bstr, including From implsSteps / History
- Implementation: Implement
ByteStrandByteStringtypes #135073 - Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- Should we call this
BStr/BString, orByteStr/ByteString? The former will be more familiar to users of thebstrcrate in the ecosystem. The latter is more explicit, and avoids potential naming conflicts (making it easier to, for instance, add it to the prelude). - Should the module be called
bstror change to something likebyte_str? Tracking Issue for ByteStr/ByteString #134915 (comment) - Should the
Displayimpl use the Unicode replacement character, or do escaping like theDebugimpl? - Add indexing for the new
std::rangetypes, or switch to it exclusively
Footnotes
Reacted by Karol Baraniecki, oxalica, Enyium, Tony Arcieri, Daniel Müller, Robbie, qb42, ahoyiski, David Hoppenbrouwers, Tim Vergenz and 3 more
Reacted by Jonas Platte, Karol Baraniecki, Thalia Archibald, LeoniePhiline, musjj, Andrew Ferreira, zk, Felix Rath, José Luis Cruz, Ragarnoy and 22 more
Reacted by 许杰友 Jieyou Xu (Joe), Geoffry Song, GrigorenkoPV, Chris, Karol Baraniecki, Thalia Archibald, musjj, Felix Rath, zk, José Luis Cruz and 7 more
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Activity
[-]Tracking Issue for BStr/BString[/-][+]Tracking Issue for ByteStr/ByteString[/+]joshtriplett commentedon Jan 3, 2025
In the course of implementing this, I'm addressing BurntSushi/bstr#190 : both the
ByteStrandByteStringtypes will implementIndexandIndexMut.Implement `ByteStr` and `ByteString` types
Implement `ByteStr` and `ByteString` types
Implement `ByteStr` and `ByteString` types
Implement `ByteStr` and `ByteString` types
Implement `ByteStr` and `ByteString` types
Implement `ByteStr` and `ByteString` types
Implement `ByteStr` and `ByteString` types
Implement `ByteStr` and `ByteString` types
Auto merge of rust-lang#135073 - joshtriplett:bstr, r=<try>
Auto merge of rust-lang#135073 - joshtriplett:bstr, r=<try>
Implement `ByteStr` and `ByteString` types
124 remaining items
Rollup merge of rust-lang#159554 - ajtribick:int_from_ascii_bytes, r=…
Rollup merge of rust-lang#159554 - ajtribick:int_from_ascii_bytes, r=…
Unrolled build for #159554
Rollup merge of #159554 - ajtribick:int_from_ascii_bytes, r=Mark-Simu…
DanielEScherzer commentedon Aug 11, 2026
In #159300 the display impl was moved to a separate feature gate (
bstr_to_string) so hopefully this doesn't block stabilization of the overall typeclarfonthey commentedon Aug 11, 2026
(FWIW, trait implementations can't be unstable, so, we're still going to need to discuss
Displayon stabilisation. But the methods at least are unstable, and we can comment out theDisplayimpl if we need.)In terms of final changes before stabilisation, I opened #160912 to rename the module to
byte_strfrombstr, which we haven't fully discussed but I assumed we wanted. If the type is going to be namedByteStrinstead ofBStr, we will want this.I'll rebase the opaque rewrite on top of that one, but I figured the module/feature rename would be easier to do first.
programmerjake commentedon Aug 11, 2026
that's no longer the case: https://github.com/rust-lang/rust/blob/712070e7e00c742aea222da41bd10f8d0de3dfeb/src/doc/rustc-dev-guide/src/stability.md#unstable_feature_bound
clarfonthey commentedon Aug 11, 2026
That also goes into the entire separate issue that I've been meaning to write up, which is that rustc-dev-guide and std-dev-guide do not have the same information and should probably be merged somehow.
clarfonthey commentedon Nov 4, 2026
Would someone on the FCP list be willing to cancel FCP here? Since we probably would want to redo FCP on the stabilization PR when it happens.
ChrisDenton commentedon Nov 4, 2026
@rfcbot canceled
rust-rfcbot commentedon Nov 4, 2026
@ChrisDenton proposal cancelled.