File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -1859,6 +1859,18 @@ where
1859
1859
B : ToOwned + ?Sized ,
1860
1860
Rc < B > : From < & ' a B > + From < B :: Owned > ,
1861
1861
{
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
+ /// ```
1862
1874
#[ inline]
1863
1875
fn from ( cow : Cow < ' a , B > ) -> Rc < B > {
1864
1876
match cow {
Original file line number Diff line number Diff line change @@ -2413,6 +2413,18 @@ where
2413
2413
B : ToOwned + ?Sized ,
2414
2414
Arc < B > : From < & ' a B > + From < B :: Owned > ,
2415
2415
{
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
+ /// ```
2416
2428
#[ inline]
2417
2429
fn from ( cow : Cow < ' a , B > ) -> Arc < B > {
2418
2430
match cow {
You can’t perform that action at this time.
0 commit comments