File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -1859,6 +1859,18 @@ where
18591859 B : ToOwned + ?Sized ,
18601860 Rc < B > : From < & ' a B > + From < B :: Owned > ,
18611861{
1862+ /// Create a reference-counted pointer from
1863+ /// a clone-on-write pointer by copying its content.
1864+ ///
1865+ /// # Example
1866+ ///
1867+ /// ```rust
1868+ /// # use std::rc::Rc;
1869+ /// # use std::borrow::Cow;
1870+ /// let cow: Cow<str> = Cow::Borrowed("eggplant");
1871+ /// let shared: Rc<str> = Rc::from(cow);
1872+ /// assert_eq!("eggplant", &shared[..]);
1873+ /// ```
18621874 #[ inline]
18631875 fn from ( cow : Cow < ' a , B > ) -> Rc < B > {
18641876 match cow {
Original file line number Diff line number Diff line change @@ -2413,6 +2413,18 @@ where
24132413 B : ToOwned + ?Sized ,
24142414 Arc < B > : From < & ' a B > + From < B :: Owned > ,
24152415{
2416+ /// Create an atomically reference-counted pointer from
2417+ /// a clone-on-write pointer by copying its content.
2418+ ///
2419+ /// # Example
2420+ ///
2421+ /// ```rust
2422+ /// # use std::sync::Arc;
2423+ /// # use std::borrow::Cow;
2424+ /// let cow: Cow<str> = Cow::Borrowed("eggplant");
2425+ /// let shared: Arc<str> = Arc::from(cow);
2426+ /// assert_eq!("eggplant", &shared[..]);
2427+ /// ```
24162428 #[ inline]
24172429 fn from ( cow : Cow < ' a , B > ) -> Arc < B > {
24182430 match cow {
You can’t perform that action at this time.
0 commit comments