about summary refs log tree commit diff
path: root/library/alloc/src
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2021-06-17 21:56:39 +0900
committerGitHub <noreply@github.com>2021-06-17 21:56:39 +0900
commit36b9a6ee73e1d8756b701049521fa8d50bfd56f1 (patch)
treeb2a22853dc2b750783995d1f7d84e36773124b14 /library/alloc/src
parentb17d9c1332693fc386f5374f0d63aae0ce5abab5 (diff)
parent2727c3b174831df54703bae1f32744550fc78b83 (diff)
downloadrust-36b9a6ee73e1d8756b701049521fa8d50bfd56f1.tar.gz
rust-36b9a6ee73e1d8756b701049521fa8d50bfd56f1.zip
Rollup merge of #85663 - fee1-dead:document-arc-from, r=m-ou-se
Document Arc::from
Diffstat (limited to 'library/alloc/src')
-rw-r--r--library/alloc/src/sync.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs
index a8fa028fc90..742a9d7ba01 100644
--- a/library/alloc/src/sync.rs
+++ b/library/alloc/src/sync.rs
@@ -2300,6 +2300,20 @@ impl<T: ?Sized + Hash> Hash for Arc<T> {
 
 #[stable(feature = "from_for_ptrs", since = "1.6.0")]
 impl<T> From<T> for Arc<T> {
+    /// Converts a `T` into an `Arc<T>`
+    ///
+    /// 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)
     }