We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 8b94744 + 5068cbc commit ac335e0Copy full SHA for ac335e0
library/alloc/src/rc.rs
@@ -1733,6 +1733,19 @@ impl<T: ?Sized> fmt::Pointer for Rc<T> {
1733
1734
#[stable(feature = "from_for_ptrs", since = "1.6.0")]
1735
impl<T> From<T> for Rc<T> {
1736
+ /// Converts a generic type `T` into a `Rc<T>`
1737
+ ///
1738
+ /// The conversion allocates on the heap and moves `t`
1739
+ /// from the stack into it.
1740
1741
+ /// # Example
1742
+ /// ```rust
1743
+ /// # use std::rc::Rc;
1744
+ /// let x = 5;
1745
+ /// let rc = Rc::new(5);
1746
1747
+ /// assert_eq!(Rc::from(x), rc);
1748
+ /// ```
1749
fn from(t: T) -> Self {
1750
Rc::new(t)
1751
}
0 commit comments