about summary refs log tree commit diff
path: root/library/alloc/src/rc.rs
diff options
context:
space:
mode:
authorBilly Sheppard <billy.sheppard@rmhedge.com>2024-05-03 00:10:40 +0000
committerZachary S <zasample18+github@gmail.com>2024-05-12 20:27:28 -0500
commit5c6326ad799511e59b1de60b25603309d5322090 (patch)
treea0ed4bd62e9313e6c4d9cfbff24c24773cc9afd3 /library/alloc/src/rc.rs
parentecbe3fd550fccd2cba17ea7e86539bf3e0bfc618 (diff)
downloadrust-5c6326ad799511e59b1de60b25603309d5322090.tar.gz
rust-5c6326ad799511e59b1de60b25603309d5322090.zip
added Default impls
reorganised attrs

removed OsStr impls

added backticks
Diffstat (limited to 'library/alloc/src/rc.rs')
-rw-r--r--library/alloc/src/rc.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs
index 45b20535675..206489876e3 100644
--- a/library/alloc/src/rc.rs
+++ b/library/alloc/src/rc.rs
@@ -2224,6 +2224,27 @@ impl<T: Default> Default for Rc<T> {
     }
 }
 
+#[cfg(not(no_global_oom_handling))]
+#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
+impl Default for Rc<str> {
+    /// Creates an empty str inside an Rc
+    #[inline]
+    fn default() -> Self {
+        Rc::from("")
+    }
+}
+
+#[cfg(not(no_global_oom_handling))]
+#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
+impl<T> Default for Rc<[T]> {
+    /// Creates an empty `[T]` inside an Rc
+    #[inline]
+    fn default() -> Self {
+        let arr: [T; 0] = [];
+        Rc::from(arr)
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 trait RcEqIdent<T: ?Sized + PartialEq, A: Allocator> {
     fn eq(&self, other: &Rc<T, A>) -> bool;