Skip to content

Commit

Permalink
Rollup merge of #85143 - fee1-dead:master, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Document Rc::from
  • Loading branch information
JohnTitor authored May 11, 2021
2 parents 06c76ea + 5068cbc commit 081dd99
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 081dd99

Please sign in to comment.