Skip to content

Commit

Permalink
Document Arc::from
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed Jun 5, 2021
1 parent a7890c7 commit 2727c3b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 2727c3b

Please sign in to comment.