about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDeadbeef <fee1-dead-beef@protonmail.com>2021-05-26 17:51:02 +0800
committerDeadbeef <fee1-dead-beef@protonmail.com>2021-05-26 14:21:44 +0000
commit3870e8a31d7c99b0127e775755d758010e6105bb (patch)
tree6130593269b5a0338433d6df3ddbddc6c55b2487
parent54bdfa125722c9ee6fadb61818f861b1102fd300 (diff)
downloadrust-3870e8a31d7c99b0127e775755d758010e6105bb.tar.gz
rust-3870e8a31d7c99b0127e775755d758010e6105bb.zip
Document `From` impls for cow.rs
-rw-r--r--library/alloc/src/vec/cow.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/library/alloc/src/vec/cow.rs b/library/alloc/src/vec/cow.rs
index 73d15d30647..64943a273c9 100644
--- a/library/alloc/src/vec/cow.rs
+++ b/library/alloc/src/vec/cow.rs
@@ -5,6 +5,12 @@ use super::Vec;
 
 #[stable(feature = "cow_from_vec", since = "1.8.0")]
 impl<'a, T: Clone> From<&'a [T]> for Cow<'a, [T]> {
+    /// Creates a [`Borrowed`] variant of [`Cow`]
+    /// from a slice.
+    ///
+    /// This conversion does not allocate or clone the data.
+    ///
+    /// [`Borrowed`]: crate::borrow::Cow::Borrowed
     fn from(s: &'a [T]) -> Cow<'a, [T]> {
         Cow::Borrowed(s)
     }
@@ -12,6 +18,12 @@ impl<'a, T: Clone> From<&'a [T]> for Cow<'a, [T]> {
 
 #[stable(feature = "cow_from_vec", since = "1.8.0")]
 impl<'a, T: Clone> From<Vec<T>> for Cow<'a, [T]> {
+    /// Creates an [`Owned`] variant of [`Cow`]
+    /// from an owned instance of [`Vec`].
+    ///
+    /// This conversion does not allocate or clone the data.
+    ///
+    /// [`Owned`]: crate::borrow::Cow::Owned
     fn from(v: Vec<T>) -> Cow<'a, [T]> {
         Cow::Owned(v)
     }
@@ -19,6 +31,12 @@ impl<'a, T: Clone> From<Vec<T>> for Cow<'a, [T]> {
 
 #[stable(feature = "cow_from_vec_ref", since = "1.28.0")]
 impl<'a, T: Clone> From<&'a Vec<T>> for Cow<'a, [T]> {
+    /// Creates a [`Borrowed`] variant of [`Cow`]
+    /// from a reference to [`Vec`].
+    ///
+    /// This conversion does not allocate or clone the data.
+    ///
+    /// [`Borrowed`]: crate::borrow::Cow::Borrowed
     fn from(v: &'a Vec<T>) -> Cow<'a, [T]> {
         Cow::Borrowed(v.as_slice())
     }