Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 5c6326a

Browse files
Billy-Sheppardzachs18
authored andcommitted
added Default impls
reorganised attrs removed OsStr impls added backticks
1 parent ecbe3fd commit 5c6326a

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

library/alloc/src/ffi/c_str.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,28 @@ impl From<&CStr> for Rc<CStr> {
910910
}
911911
}
912912

913+
#[cfg(not(no_global_oom_handling))]
914+
#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
915+
impl Default for Arc<CStr> {
916+
/// Creates an empty CStr inside an Arc
917+
#[inline]
918+
fn default() -> Self {
919+
let c_str: &CStr = Default::default();
920+
Arc::from(c_str)
921+
}
922+
}
923+
924+
#[cfg(not(no_global_oom_handling))]
925+
#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
926+
impl Default for Rc<CStr> {
927+
/// Creates an empty CStr inside an Rc
928+
#[inline]
929+
fn default() -> Self {
930+
let c_str: &CStr = Default::default();
931+
Rc::from(c_str)
932+
}
933+
}
934+
913935
#[cfg(not(test))]
914936
#[stable(feature = "default_box_extra", since = "1.17.0")]
915937
impl Default for Box<CStr> {

library/alloc/src/rc.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,6 +2224,27 @@ impl<T: Default> Default for Rc<T> {
22242224
}
22252225
}
22262226

2227+
#[cfg(not(no_global_oom_handling))]
2228+
#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
2229+
impl Default for Rc<str> {
2230+
/// Creates an empty str inside an Rc
2231+
#[inline]
2232+
fn default() -> Self {
2233+
Rc::from("")
2234+
}
2235+
}
2236+
2237+
#[cfg(not(no_global_oom_handling))]
2238+
#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
2239+
impl<T> Default for Rc<[T]> {
2240+
/// Creates an empty `[T]` inside an Rc
2241+
#[inline]
2242+
fn default() -> Self {
2243+
let arr: [T; 0] = [];
2244+
Rc::from(arr)
2245+
}
2246+
}
2247+
22272248
#[stable(feature = "rust1", since = "1.0.0")]
22282249
trait RcEqIdent<T: ?Sized + PartialEq, A: Allocator> {
22292250
fn eq(&self, other: &Rc<T, A>) -> bool;

library/alloc/src/sync.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3300,6 +3300,27 @@ impl<T: Default> Default for Arc<T> {
33003300
}
33013301
}
33023302

3303+
#[cfg(not(no_global_oom_handling))]
3304+
#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
3305+
impl Default for Arc<str> {
3306+
/// Creates an empty str inside an Arc
3307+
#[inline]
3308+
fn default() -> Self {
3309+
Arc::from("")
3310+
}
3311+
}
3312+
3313+
#[cfg(not(no_global_oom_handling))]
3314+
#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
3315+
impl<T> Default for Arc<[T]> {
3316+
/// Creates an empty `[T]` inside an Arc
3317+
#[inline]
3318+
fn default() -> Self {
3319+
let arr: [T; 0] = [];
3320+
Arc::from(arr)
3321+
}
3322+
}
3323+
33033324
#[stable(feature = "rust1", since = "1.0.0")]
33043325
impl<T: ?Sized + Hash, A: Allocator> Hash for Arc<T, A> {
33053326
fn hash<H: Hasher>(&self, state: &mut H) {

0 commit comments

Comments
 (0)