///
/// let five = Arc::new(5);
/// ```
+ #[cfg(not(no_global_oom_handling))]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn new(data: T) -> Arc<T> {
/// me: me.clone(),
/// });
/// ```
+ #[cfg(not(no_global_oom_handling))]
#[inline]
#[unstable(feature = "arc_new_cyclic", issue = "75861")]
pub fn new_cyclic(data_fn: impl FnOnce(&Weak<T>) -> T) -> Arc<T> {
/// Constructs a new `Pin<Arc<T>>`. If `T` does not implement `Unpin`, then
/// `data` will be pinned in memory and unable to be moved.
+ #[cfg(not(no_global_oom_handling))]
#[stable(feature = "pin", since = "1.33.0")]
pub fn pin(data: T) -> Pin<Arc<T>> {
unsafe { Pin::new_unchecked(Arc::new(data)) }
}
+ /// Constructs a new `Pin<Arc<T>>`, return an error if allocation fails.
+ #[unstable(feature = "allocator_api", issue = "32838")]
+ #[inline]
+ pub fn try_pin(data: T) -> Result<Pin<Arc<T>>, AllocError> {
+ unsafe { Ok(Pin::new_unchecked(Arc::try_new(data)?)) }
+ }
+
/// Constructs a new `Arc<T>`, returning an error if allocation fails.
///
/// # Examples
}
}
+#[cfg(not(no_global_oom_handling))]
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Default> Default for Arc<T> {
/// Creates a new `Arc<T>`, with the `Default` value for `T`.
}
}
+#[cfg(not(no_global_oom_handling))]
#[stable(feature = "from_for_ptrs", since = "1.6.0")]
impl<T> From<T> for Arc<T> {
/// Converts a `T` into an `Arc<T>`