diff options
| author | bors <bors@rust-lang.org> | 2021-06-04 04:50:36 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-06-04 04:50:36 +0000 |
| commit | 4afa3a80926f52aa361fe4e89643dac2e2e57f34 (patch) | |
| tree | c0693324bfe3de1c7c5465330e084cd7ccffd85f /library/alloc | |
| parent | 1c82bb293c83877b52380d0d7a181a011fb70603 (diff) | |
| parent | edb8f653e768361eb6191b5bbe2f31087394d79d (diff) | |
Auto merge of #85984 - JohnTitor:rollup-rq0g9ph, r=JohnTitor
Rollup of 8 pull requests
Successful merges:
- #85717 (Document `From` impls for cow.rs)
- #85850 (Remove unused feature gates)
- #85888 (Fix typo in internal documentation for `TrustedRandomAccess`)
- #85889 (Restoring the `num_def_ids` function in the CStore API )
- #85899 (jsondocck small cleanup)
- #85937 (Fix bad suggestions for code from proc_macro)
- #85963 (Show `::{{constructor}}` in std::any::type_name().)
- #85977 (Fix linkcheck script from getting out of sync.)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'library/alloc')
| -rw-r--r-- | library/alloc/src/vec/cow.rs | 18 |
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()) } |
