Skip to content

Commit

Permalink
Document Rc::from
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed May 10, 2021
1 parent 00f2bf4 commit 5068cbc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions library/alloc/src/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 5068cbc

Please sign in to comment.