diff options
| author | Deadbeef <fee1-dead-beef@protonmail.com> | 2021-05-10 18:46:13 +0800 |
|---|---|---|
| committer | Deadbeef <fee1-dead-beef@protonmail.com> | 2021-05-10 18:46:13 +0800 |
| commit | 5068cbc90184699eb35507a6d6acd347fc0627be (patch) | |
| tree | 28a70828e6c710600144b511d46ab0c1e848a16e /library/alloc | |
| parent | 00f2bf40d6374ec3541a72edb5b481fb1370dbca (diff) | |
| download | rust-5068cbc90184699eb35507a6d6acd347fc0627be.tar.gz rust-5068cbc90184699eb35507a6d6acd347fc0627be.zip | |
Document Rc::from
Diffstat (limited to 'library/alloc')
| -rw-r--r-- | library/alloc/src/rc.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index 964169a227f..800952f7a5e 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -1733,6 +1733,19 @@ impl<T: ?Sized> fmt::Pointer for Rc<T> { #[stable(feature = "from_for_ptrs", since = "1.6.0")] impl<T> From<T> for Rc<T> { + /// Converts a generic type `T` into a `Rc<T>` + /// + /// The conversion allocates on the heap and moves `t` + /// from the stack into it. + /// + /// # Example + /// ```rust + /// # use std::rc::Rc; + /// let x = 5; + /// let rc = Rc::new(5); + /// + /// assert_eq!(Rc::from(x), rc); + /// ``` fn from(t: T) -> Self { Rc::new(t) } |
