diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index 964169a227f64..800952f7a5ece 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -1733,6 +1733,19 @@ impl fmt::Pointer for Rc { #[stable(feature = "from_for_ptrs", since = "1.6.0")] impl From for Rc { + /// Converts a generic type `T` into a `Rc` + /// + /// 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) }