diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2022-04-26 13:22:26 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-26 13:22:26 +0200 |
| commit | eaf8beb3f32b089b426a435794214ee0eaed8fec (patch) | |
| tree | ca85f6e081ca6bd1b018ce006a269130d03d4b9b | |
| parent | d6a57d3730a4e523c433e5528988a2a4f111e94e (diff) | |
| parent | 9f4934ec19af7fe970fc1278973ec5763ea0312c (diff) | |
| download | rust-eaf8beb3f32b089b426a435794214ee0eaed8fec.tar.gz rust-eaf8beb3f32b089b426a435794214ee0eaed8fec.zip | |
Rollup merge of #94022 - jongiddy:cow-into-owned-docs, r=Dylan-DPC
Clarify that `Cow::into_owned` returns owned data Two sections of the `Cow::into_owned` docs imply that `into_owned` returns a `Cow`. Clarify that it returns the underlying owned object, either cloned or extracted from the `Cow`.
| -rw-r--r-- | library/alloc/src/borrow.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/library/alloc/src/borrow.rs b/library/alloc/src/borrow.rs index 8b13e36c4b3..cb4e438f8be 100644 --- a/library/alloc/src/borrow.rs +++ b/library/alloc/src/borrow.rs @@ -292,8 +292,7 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> { /// /// # Examples /// - /// Calling `into_owned` on a `Cow::Borrowed` clones the underlying data - /// and becomes a `Cow::Owned`: + /// Calling `into_owned` on a `Cow::Borrowed` returns a clone of the borrowed data: /// /// ``` /// use std::borrow::Cow; @@ -307,7 +306,8 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> { /// ); /// ``` /// - /// Calling `into_owned` on a `Cow::Owned` is a no-op: + /// Calling `into_owned` on a `Cow::Owned` returns the owned data. The data is moved out of the + /// `Cow` without being cloned. /// /// ``` /// use std::borrow::Cow; |
