Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 72 additions & 72 deletions library/alloc/src/bstr.rs → library/alloc/src/byte_str.rs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
#![feature(async_fn_traits)]
#![feature(async_iterator)]
#![feature(borrowed_buf_init)]
#![feature(bstr)]
#![feature(bstr_internals)]
#![feature(byte_str)]
#![feature(byte_str_internals)]
#![feature(can_vector)]
#![feature(case_ignorable)]
#![feature(cast_maybe_uninit)]
Expand Down Expand Up @@ -246,8 +246,8 @@ pub mod alloc;
// to allow code to have `use boxed::Box;` declarations.
pub mod borrow;
pub mod boxed;
#[unstable(feature = "bstr", issue = "134915")]
pub mod bstr;
#[unstable(feature = "byte_str", issue = "134915")]
pub mod byte_str;
pub mod collections;
#[cfg(all(not(no_rc), not(no_sync), not(no_global_oom_handling)))]
pub mod ffi;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use alloc::bstr::ByteString;
use alloc::byte_str::ByteString;
use core::assert_matches;

#[test]
Expand Down
6 changes: 3 additions & 3 deletions library/alloctests/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#![feature(binary_heap_into_iter_sorted)]
#![feature(binary_heap_pop_if)]
#![feature(borrowed_buf_init)]
#![feature(bstr)]
#![feature(bstr_to_string)]
#![feature(buf_read_has_data_left)]
#![feature(byte_str)]
#![feature(byte_str_to_string)]
#![feature(can_vector)]
#![feature(casefold)]
#![feature(const_btree_len)]
Expand Down Expand Up @@ -73,8 +73,8 @@ mod arc;
mod autotraits;
mod borrow;
mod boxed;
mod bstr;
mod btree_set_hash;
mod byte_str;
mod c_str;
mod c_str2;
mod collections;
Expand Down
70 changes: 35 additions & 35 deletions library/core/src/bstr/mod.rs → library/core/src/byte_str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

mod traits;

#[unstable(feature = "bstr_internals", issue = "none")]
#[unstable(feature = "byte_str_internals", issue = "none")]
pub use traits::{impl_partial_eq, impl_partial_eq_n, impl_partial_eq_ord};

use crate::borrow::{Borrow, BorrowMut};
Expand All @@ -17,7 +17,7 @@ use crate::ops::{Deref, DerefMut, DerefPure};
/// need to round-trip whatever data the user provides.
///
/// For an owned, growable byte string buffer, use
/// [`ByteString`](../../std/bstr/struct.ByteString.html).
/// [`ByteString`](../../std/byte_str/struct.ByteString.html).
///
/// `ByteStr` implements `Deref` to `[u8]`, so all methods available on `[u8]` are available on
/// `ByteStr`.
Expand All @@ -37,7 +37,7 @@ use crate::ops::{Deref, DerefMut, DerefPure};
///
/// The `Display` implementation behaves as if the `ByteStr` were first lossily converted to a
/// `str`, with invalid UTF-8 presented as the Unicode replacement character (�).
#[unstable(feature = "bstr", issue = "134915")]
#[unstable(feature = "byte_str", issue = "134915")]
#[rustc_has_incoherent_inherent_impls]
#[repr(transparent)]
#[doc(alias = "BStr")]
Expand All @@ -53,8 +53,8 @@ impl ByteStr {
/// You can create a `ByteStr` from a byte array, a byte slice or a string slice:
///
/// ```
/// # #![feature(bstr)]
/// # use std::bstr::ByteStr;
/// # #![feature(byte_str)]
/// # use std::byte_str::ByteStr;
/// let a = ByteStr::new(b"abc");
/// let b = ByteStr::new(&b"abc"[..]);
/// let c = ByteStr::new("abc");
Expand All @@ -63,7 +63,7 @@ impl ByteStr {
/// assert_eq!(a, c);
/// ```
#[inline]
#[unstable(feature = "bstr", issue = "134915")]
#[unstable(feature = "byte_str", issue = "134915")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
pub const fn new<B: ?Sized + [const] AsRef<[u8]>>(bytes: &B) -> &Self {
ByteStr::from_bytes(bytes.as_ref())
Expand All @@ -76,7 +76,7 @@ impl ByteStr {
/// for example `Box<ByteStr>` or `Arc<ByteStr>`.
#[inline]
// #[unstable(feature = "str_as_str", issue = "130366")]
#[unstable(feature = "bstr", issue = "134915")]
#[unstable(feature = "byte_str", issue = "134915")]
pub const fn as_byte_str(&self) -> &ByteStr {
self
}
Expand All @@ -88,49 +88,49 @@ impl ByteStr {
/// for example `Box<ByteStr>` or `MutexGuard<ByteStr>`.
#[inline]
// #[unstable(feature = "str_as_str", issue = "130366")]
#[unstable(feature = "bstr", issue = "134915")]
#[unstable(feature = "byte_str", issue = "134915")]
pub const fn as_mut_byte_str(&mut self) -> &mut ByteStr {
self
}

#[doc(hidden)]
#[unstable(feature = "bstr_internals", issue = "none")]
#[unstable(feature = "byte_str_internals", issue = "none")]
#[inline]
#[rustc_const_unstable(feature = "bstr_internals", issue = "none")]
#[rustc_const_unstable(feature = "byte_str_internals", issue = "none")]
pub const fn from_bytes(slice: &[u8]) -> &Self {
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`, so we can turn a reference to
// the wrapped type into a reference to the wrapper type.
unsafe { &*(slice as *const [u8] as *const Self) }
}

#[doc(hidden)]
#[unstable(feature = "bstr_internals", issue = "none")]
#[unstable(feature = "byte_str_internals", issue = "none")]
#[inline]
#[rustc_const_unstable(feature = "bstr_internals", issue = "none")]
#[rustc_const_unstable(feature = "byte_str_internals", issue = "none")]
pub const fn from_bytes_mut(slice: &mut [u8]) -> &mut Self {
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`, so we can turn a reference to
// the wrapped type into a reference to the wrapper type.
unsafe { &mut *(slice as *mut [u8] as *mut Self) }
}

#[doc(hidden)]
#[unstable(feature = "bstr_internals", issue = "none")]
#[unstable(feature = "byte_str_internals", issue = "none")]
#[inline]
#[rustc_const_unstable(feature = "bstr_internals", issue = "none")]
#[rustc_const_unstable(feature = "byte_str_internals", issue = "none")]
pub const fn as_bytes(&self) -> &[u8] {
&self.0
}

#[doc(hidden)]
#[unstable(feature = "bstr_internals", issue = "none")]
#[unstable(feature = "byte_str_internals", issue = "none")]
#[inline]
#[rustc_const_unstable(feature = "bstr_internals", issue = "none")]
#[rustc_const_unstable(feature = "byte_str_internals", issue = "none")]
pub const fn as_bytes_mut(&mut self) -> &mut [u8] {
&mut self.0
}
}

#[unstable(feature = "bstr", issue = "134915")]
#[unstable(feature = "byte_str", issue = "134915")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
const impl Deref for ByteStr {
type Target = [u8];
Expand All @@ -141,7 +141,7 @@ const impl Deref for ByteStr {
}
}

#[unstable(feature = "bstr", issue = "134915")]
#[unstable(feature = "byte_str", issue = "134915")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
const impl DerefMut for ByteStr {
#[inline]
Expand All @@ -153,7 +153,7 @@ const impl DerefMut for ByteStr {
#[unstable(feature = "deref_pure_trait", issue = "87121")]
unsafe impl DerefPure for ByteStr {}

#[unstable(feature = "bstr", issue = "134915")]
#[unstable(feature = "byte_str", issue = "134915")]
impl fmt::Debug for ByteStr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "\"")?;
Expand All @@ -172,7 +172,7 @@ impl fmt::Debug for ByteStr {
}
}

#[unstable(feature = "bstr_to_string", issue = "134915")]
#[unstable(feature = "byte_str_to_string", issue = "134915")]
impl fmt::Display for ByteStr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fn emit(byte_str: &ByteStr, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down Expand Up @@ -257,7 +257,7 @@ impl fmt::Display for ByteStr {
}
}

#[unstable(feature = "bstr", issue = "134915")]
#[unstable(feature = "byte_str", issue = "134915")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
const impl AsRef<[u8]> for ByteStr {
#[inline]
Expand All @@ -266,7 +266,7 @@ const impl AsRef<[u8]> for ByteStr {
}
}

#[unstable(feature = "bstr", issue = "134915")]
#[unstable(feature = "byte_str", issue = "134915")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
const impl AsRef<ByteStr> for ByteStr {
#[inline]
Expand All @@ -277,7 +277,7 @@ const impl AsRef<ByteStr> for ByteStr {

// `impl AsRef<ByteStr> for [u8]` omitted to avoid widespread inference failures

#[unstable(feature = "bstr", issue = "134915")]
#[unstable(feature = "byte_str", issue = "134915")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
const impl AsRef<ByteStr> for str {
#[inline]
Expand All @@ -286,7 +286,7 @@ const impl AsRef<ByteStr> for str {
}
}

#[unstable(feature = "bstr", issue = "134915")]
#[unstable(feature = "byte_str", issue = "134915")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
const impl AsMut<[u8]> for ByteStr {
#[inline]
Expand All @@ -301,7 +301,7 @@ const impl AsMut<[u8]> for ByteStr {

// `impl Borrow<ByteStr> for str` omitted to avoid widespread inference failures

#[unstable(feature = "bstr", issue = "134915")]
#[unstable(feature = "byte_str", issue = "134915")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
const impl Borrow<[u8]> for ByteStr {
#[inline]
Expand All @@ -312,7 +312,7 @@ const impl Borrow<[u8]> for ByteStr {

// `impl BorrowMut<ByteStr> for [u8]` omitted to avoid widespread inference failures

#[unstable(feature = "bstr", issue = "134915")]
#[unstable(feature = "byte_str", issue = "134915")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
const impl BorrowMut<[u8]> for ByteStr {
#[inline]
Expand All @@ -321,14 +321,14 @@ const impl BorrowMut<[u8]> for ByteStr {
}
}

#[unstable(feature = "bstr", issue = "134915")]
#[unstable(feature = "byte_str", issue = "134915")]
impl<'a> Default for &'a ByteStr {
fn default() -> Self {
ByteStr::from_bytes(b"")
}
}

#[unstable(feature = "bstr", issue = "134915")]
#[unstable(feature = "byte_str", issue = "134915")]
impl<'a> Default for &'a mut ByteStr {
fn default() -> Self {
ByteStr::from_bytes_mut(&mut [])
Expand All @@ -337,15 +337,15 @@ impl<'a> Default for &'a mut ByteStr {

// Omitted due to inference failures
//
// #[unstable(feature = "bstr", issue = "134915")]
// #[unstable(feature = "byte_str", issue = "134915")]
// impl<'a, const N: usize> From<&'a [u8; N]> for &'a ByteStr {
// #[inline]
// fn from(s: &'a [u8; N]) -> Self {
// ByteStr::from_bytes(s)
// }
// }
//
// #[unstable(feature = "bstr", issue = "134915")]
// #[unstable(feature = "byte_str", issue = "134915")]
// impl<'a> From<&'a [u8]> for &'a ByteStr {
// #[inline]
// fn from(s: &'a [u8]) -> Self {
Expand All @@ -355,15 +355,15 @@ impl<'a> Default for &'a mut ByteStr {

// Omitted due to slice-from-array-issue-113238:
//
// #[unstable(feature = "bstr", issue = "134915")]
// #[unstable(feature = "byte_str", issue = "134915")]
// impl<'a> From<&'a ByteStr> for &'a [u8] {
// #[inline]
// fn from(s: &'a ByteStr) -> Self {
// &s.0
// }
// }
//
// #[unstable(feature = "bstr", issue = "134915")]
// #[unstable(feature = "byte_str", issue = "134915")]
// impl<'a> From<&'a mut ByteStr> for &'a mut [u8] {
// #[inline]
// fn from(s: &'a mut ByteStr) -> Self {
Expand All @@ -373,15 +373,15 @@ impl<'a> Default for &'a mut ByteStr {

// Omitted due to inference failures
//
// #[unstable(feature = "bstr", issue = "134915")]
// #[unstable(feature = "byte_str", issue = "134915")]
// impl<'a> From<&'a str> for &'a ByteStr {
// #[inline]
// fn from(s: &'a str) -> Self {
// ByteStr::from_bytes(s.as_bytes())
// }
// }

#[unstable(feature = "bstr", issue = "134915")]
#[unstable(feature = "byte_str", issue = "134915")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
const impl<'a> TryFrom<&'a ByteStr> for &'a str {
type Error = crate::str::Utf8Error;
Expand All @@ -392,7 +392,7 @@ const impl<'a> TryFrom<&'a ByteStr> for &'a str {
}
}

#[unstable(feature = "bstr", issue = "134915")]
#[unstable(feature = "byte_str", issue = "134915")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
const impl<'a> TryFrom<&'a mut ByteStr> for &'a mut str {
type Error = crate::str::Utf8Error;
Expand Down
Loading
Loading