Skip to content

Commit

Permalink
Rollup merge of rust-lang#94022 - jongiddy:cow-into-owned-docs, r=Dyl…
Browse files Browse the repository at this point in the history
…an-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`.
  • Loading branch information
GuillaumeGomez authored Apr 26, 2022
2 parents d6a57d3 + 9f4934e commit 24dcda0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions library/alloc/src/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 24dcda0

Please sign in to comment.