Rollup merge of #85663 - fee1-dead:document-arc-from, r=m-ou-se

Document Arc::from
This commit is contained in:
Yuki Okushi 2021-06-17 21:56:39 +09:00 committed by GitHub
commit 36b9a6ee73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2300,6 +2300,20 @@ impl<T: ?Sized + Hash> Hash for Arc<T> {
#[stable(feature = "from_for_ptrs", since = "1.6.0")] #[stable(feature = "from_for_ptrs", since = "1.6.0")]
impl<T> From<T> for Arc<T> { 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 { fn from(t: T) -> Self {
Arc::new(t) Arc::new(t)
} }