Skip to content

Commit

Permalink
Support no_rc, no_sync, and no_global_oom_handling
Browse files Browse the repository at this point in the history
For now, apply `no_global_oom_handling` to all of
library/alloc/src/bstr.rs . We can make it more fine-grained later.
  • Loading branch information
joshtriplett committed Jan 6, 2025
1 parent f035281 commit 9ccc52b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions library/alloc/src/bstr.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! The `ByteStr` and `ByteString` types and trait implementations.
// This could be more fine-grained.
#![cfg(not(no_global_oom_handling))]

use core::borrow::{Borrow, BorrowMut};
#[unstable(feature = "bstr", issue = "134915")]
pub use core::bstr::ByteStr;
Expand All @@ -17,8 +20,10 @@ use core::{fmt, hash};
use crate::borrow::{Cow, ToOwned};
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
use crate::boxed::Box;
#[cfg(not(no_rc))]
use crate::rc::Rc;
use crate::string::String;
#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
use crate::sync::Arc;
use crate::vec::Vec;

Expand Down Expand Up @@ -664,6 +669,7 @@ impl From<Box<ByteStr>> for Box<[u8]> {
}

#[unstable(feature = "bstr", issue = "134915")]
#[cfg(not(no_rc))]
impl From<Rc<[u8]>> for Rc<ByteStr> {
#[inline]
fn from(s: Rc<[u8]>) -> Rc<ByteStr> {
Expand All @@ -673,6 +679,7 @@ impl From<Rc<[u8]>> for Rc<ByteStr> {
}

#[unstable(feature = "bstr", issue = "134915")]
#[cfg(not(no_rc))]
impl From<Rc<ByteStr>> for Rc<[u8]> {
#[inline]
fn from(s: Rc<ByteStr>) -> Rc<[u8]> {
Expand All @@ -682,6 +689,7 @@ impl From<Rc<ByteStr>> for Rc<[u8]> {
}

#[unstable(feature = "bstr", issue = "134915")]
#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
impl From<Arc<[u8]>> for Arc<ByteStr> {
#[inline]
fn from(s: Arc<[u8]>) -> Arc<ByteStr> {
Expand All @@ -691,6 +699,7 @@ impl From<Arc<[u8]>> for Arc<ByteStr> {
}

#[unstable(feature = "bstr", issue = "134915")]
#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
impl From<Arc<ByteStr>> for Arc<[u8]> {
#[inline]
fn from(s: Arc<ByteStr>) -> Arc<[u8]> {
Expand Down

0 comments on commit 9ccc52b

Please sign in to comment.