Skip to content

Commit 1466595

Browse files
added Default impls
reorganised attrs removed OsStr impls added backticks
1 parent d287f3e commit 1466595

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

library/alloc/src/ffi/c_str.rs

+22
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

+21
Original file line numberDiff line numberDiff line change
@@ -2226,6 +2226,27 @@ impl<T: Default> Default for Rc<T> {
22262226
}
22272227
}
22282228

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

library/alloc/src/sync.rs

+21
Original file line numberDiff line numberDiff line change
@@ -3298,6 +3298,27 @@ impl<T: Default> Default for Arc<T> {
32983298
}
32993299
}
33003300

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

0 commit comments

Comments
 (0)