Skip to content

Commit 24dcda0

Browse files
Rollup merge of rust-lang#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`.
2 parents d6a57d3 + 9f4934e commit 24dcda0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

library/alloc/src/borrow.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,7 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
292292
///
293293
/// # Examples
294294
///
295-
/// Calling `into_owned` on a `Cow::Borrowed` clones the underlying data
296-
/// and becomes a `Cow::Owned`:
295+
/// Calling `into_owned` on a `Cow::Borrowed` returns a clone of the borrowed data:
297296
///
298297
/// ```
299298
/// use std::borrow::Cow;
@@ -307,7 +306,8 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
307306
/// );
308307
/// ```
309308
///
310-
/// Calling `into_owned` on a `Cow::Owned` is a no-op:
309+
/// Calling `into_owned` on a `Cow::Owned` returns the owned data. The data is moved out of the
310+
/// `Cow` without being cloned.
311311
///
312312
/// ```
313313
/// use std::borrow::Cow;

0 commit comments

Comments
 (0)