Skip to content

Commit ac335e0

Browse files
authored
Rollup merge of #85143 - fee1-dead:master, r=Mark-Simulacrum
Document Rc::from
2 parents 8b94744 + 5068cbc commit ac335e0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

library/alloc/src/rc.rs

+13
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,19 @@ impl<T: ?Sized> fmt::Pointer for Rc<T> {
17331733

17341734
#[stable(feature = "from_for_ptrs", since = "1.6.0")]
17351735
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+
/// ```
17361749
fn from(t: T) -> Self {
17371750
Rc::new(t)
17381751
}

0 commit comments

Comments
 (0)