mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
Rollup merge of #85663 - fee1-dead:document-arc-from, r=m-ou-se
Document Arc::from
This commit is contained in:
commit
36b9a6ee73
@ -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