We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 104a3c3 commit 9d38ce3Copy full SHA for 9d38ce3
library/alloc/src/sync.rs
@@ -489,6 +489,13 @@ impl<T> Arc<T> {
489
pub fn pin(data: T) -> Pin<Arc<T>> {
490
unsafe { Pin::new_unchecked(Arc::new(data)) }
491
}
492
+
493
+ /// Constructs a new `Pin<Arc<T>>, return an error if allocation fails.
494
+ #[unstable(feature = "allocator_api", issue = "32838")]
495
+ #[inline]
496
+ pub fn try_pin(data: T) -> Result<Pin<Arc<T>>, AllocError> {
497
+ unsafe { Ok(Pin::new_unchecked(Arc::try_new(data)?)) }
498
+ }
499
500
/// Constructs a new `Arc<T>`, returning an error if allocation fails.
501
///
0 commit comments