Skip to content

Commit 2727c3b

Browse files
committed
Document Arc::from
1 parent a7890c7 commit 2727c3b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

library/alloc/src/sync.rs

+14
Original file line numberDiff line numberDiff line change
@@ -2300,6 +2300,20 @@ impl<T: ?Sized + Hash> Hash for Arc<T> {
23002300

23012301
#[stable(feature = "from_for_ptrs", since = "1.6.0")]
23022302
impl<T> From<T> for Arc<T> {
2303+
/// Converts a `T` into an `Arc<T>`
2304+
///
2305+
/// The conversion moves the value into a
2306+
/// newly allocated `Arc`. It is equivalent to
2307+
/// calling `Arc::new(t)`.
2308+
///
2309+
/// # Example
2310+
/// ```rust
2311+
/// # use std::sync::Arc;
2312+
/// let x = 5;
2313+
/// let arc = Arc::new(5);
2314+
///
2315+
/// assert_eq!(Arc::from(x), arc);
2316+
/// ```
23032317
fn from(t: T) -> Self {
23042318
Arc::new(t)
23052319
}

0 commit comments

Comments
 (0)