From 2727c3b174831df54703bae1f32744550fc78b83 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Tue, 25 May 2021 10:07:56 +0000 Subject: [PATCH] Document Arc::from --- library/alloc/src/sync.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 17927f5f5fdc4..9ae133d2c8c96 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -2300,6 +2300,20 @@ impl Hash for Arc { #[stable(feature = "from_for_ptrs", since = "1.6.0")] impl From for Arc { + /// Converts a `T` into an `Arc` + /// + /// The conversion moves the value into a + /// newly allocated `Arc`. It is equivalent to + /// calling `Arc::new(t)`. + /// + /// # Example + /// ```rust + /// # use std::sync::Arc; + /// let x = 5; + /// let arc = Arc::new(5); + /// + /// assert_eq!(Arc::from(x), arc); + /// ``` fn from(t: T) -> Self { Arc::new(t) }