about summary refs log tree commit diff
path: root/library/alloc/src/sync.rs
diff options
context:
space:
mode:
authorJules Bertholet <julesbertholet@quoi.xyz>2025-07-15 17:41:31 -0400
committerJules Bertholet <julesbertholet@quoi.xyz>2025-07-15 17:41:31 -0400
commit87dd4695fe5fe2e76999d5040deb20a018e21942 (patch)
tree39f20a8c990a437e0b610cf003b7c3c80d4de614 /library/alloc/src/sync.rs
parent607fbd8d3e25997737a0bf25b215e581b922f1b0 (diff)
downloadrust-87dd4695fe5fe2e76999d5040deb20a018e21942.tar.gz
rust-87dd4695fe5fe2e76999d5040deb20a018e21942.zip
Add `Default` impls for `Pin`ned `Box`, `Rc`, `Arc`
Diffstat (limited to 'library/alloc/src/sync.rs')
-rw-r--r--library/alloc/src/sync.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs
index b8925f4544f..29caa7bc539 100644
--- a/library/alloc/src/sync.rs
+++ b/library/alloc/src/sync.rs
@@ -3654,6 +3654,19 @@ impl<T> Default for Arc<[T]> {
     }
 }
 
+#[cfg(not(no_global_oom_handling))]
+#[stable(feature = "pin_default_impls", since = "CURRENT_RUSTC_VERSION")]
+impl<T> Default for Pin<Arc<T>>
+where
+    T: ?Sized,
+    Arc<T>: Default,
+{
+    #[inline]
+    fn default() -> Self {
+        unsafe { Pin::new_unchecked(Arc::<T>::default()) }
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: ?Sized + Hash, A: Allocator> Hash for Arc<T, A> {
     fn hash<H: Hasher>(&self, state: &mut H) {