diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2020-11-05 10:29:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-05 10:29:46 +0100 |
| commit | 43e1b58bccf7e62bcccfd1ce0bedc9dc65df3564 (patch) | |
| tree | 48fd373b32783ca019b40de23052cea3e0af9c5d | |
| parent | cbf74bc4ca3f9a3b17af672930c56fa25861b21e (diff) | |
| parent | 93fa023111ddfa1997e32b117a3fff01c03c4db1 (diff) | |
| download | rust-43e1b58bccf7e62bcccfd1ce0bedc9dc65df3564.tar.gz rust-43e1b58bccf7e62bcccfd1ce0bedc9dc65df3564.zip | |
Rollup merge of #78716 - est31:array_traits, r=Dylan-DPC
Array trait impl comment/doc fixes Two small doc/comment fixes regarding trait implementations on arrays.
| -rw-r--r-- | library/core/src/array/mod.rs | 5 | ||||
| -rw-r--r-- | library/std/src/primitive_docs.rs | 9 |
2 files changed, 6 insertions, 8 deletions
diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs index 1d55a5ef659..123a191dd2c 100644 --- a/library/core/src/array/mod.rs +++ b/library/core/src/array/mod.rs @@ -353,8 +353,9 @@ impl<T: Ord, const N: usize> Ord for [T; N] { } } -// The Default impls cannot be generated using the array_impls! macro because -// they require array literals. +// The Default impls cannot be done with const generics because `[T; 0]` doesn't +// require Default to be implemented, and having different impl blocks for +// different numbers isn't supported yet. macro_rules! array_impl_default { {$n:expr, $t:ident $($ts:ident)*} => { diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index ae678479234..88ab671b94e 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -491,6 +491,8 @@ mod prim_pointer {} /// /// Arrays of *any* size implement the following traits if the element type allows it: /// +/// - [`Copy`] +/// - [`Clone`] /// - [`Debug`] /// - [`IntoIterator`] (implemented for `&[T; N]` and `&mut [T; N]`) /// - [`PartialEq`], [`PartialOrd`], [`Eq`], [`Ord`] @@ -498,15 +500,10 @@ mod prim_pointer {} /// - [`AsRef`], [`AsMut`] /// - [`Borrow`], [`BorrowMut`] /// -/// Arrays of sizes from 0 to 32 (inclusive) implement [`Default`] trait +/// Arrays of sizes from 0 to 32 (inclusive) implement the [`Default`] trait /// if the element type allows it. As a stopgap, trait implementations are /// statically generated up to size 32. /// -/// Arrays of *any* size are [`Copy`] if the element type is [`Copy`] -/// and [`Clone`] if the element type is [`Clone`]. This works -/// because [`Copy`] and [`Clone`] traits are specially known -/// to the compiler. -/// /// Arrays coerce to [slices (`[T]`)][slice], so a slice method may be called on /// an array. Indeed, this provides most of the API for working with arrays. /// Slices have a dynamic size and do not coerce to arrays. |
