mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
Document Arc::from
This commit is contained in:
parent
a7890c7952
commit
2727c3b174
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user