Skip to content

Commit 43e1b58

Browse files
authored
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.
2 parents cbf74bc + 93fa023 commit 43e1b58

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

library/core/src/array/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,9 @@ impl<T: Ord, const N: usize> Ord for [T; N] {
353353
}
354354
}
355355

356-
// The Default impls cannot be generated using the array_impls! macro because
357-
// they require array literals.
356+
// The Default impls cannot be done with const generics because `[T; 0]` doesn't
357+
// require Default to be implemented, and having different impl blocks for
358+
// different numbers isn't supported yet.
358359

359360
macro_rules! array_impl_default {
360361
{$n:expr, $t:ident $($ts:ident)*} => {

library/std/src/primitive_docs.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -491,22 +491,19 @@ mod prim_pointer {}
491491
///
492492
/// Arrays of *any* size implement the following traits if the element type allows it:
493493
///
494+
/// - [`Copy`]
495+
/// - [`Clone`]
494496
/// - [`Debug`]
495497
/// - [`IntoIterator`] (implemented for `&[T; N]` and `&mut [T; N]`)
496498
/// - [`PartialEq`], [`PartialOrd`], [`Eq`], [`Ord`]
497499
/// - [`Hash`]
498500
/// - [`AsRef`], [`AsMut`]
499501
/// - [`Borrow`], [`BorrowMut`]
500502
///
501-
/// Arrays of sizes from 0 to 32 (inclusive) implement [`Default`] trait
503+
/// Arrays of sizes from 0 to 32 (inclusive) implement the [`Default`] trait
502504
/// if the element type allows it. As a stopgap, trait implementations are
503505
/// statically generated up to size 32.
504506
///
505-
/// Arrays of *any* size are [`Copy`] if the element type is [`Copy`]
506-
/// and [`Clone`] if the element type is [`Clone`]. This works
507-
/// because [`Copy`] and [`Clone`] traits are specially known
508-
/// to the compiler.
509-
///
510507
/// Arrays coerce to [slices (`[T]`)][slice], so a slice method may be called on
511508
/// an array. Indeed, this provides most of the API for working with arrays.
512509
/// Slices have a dynamic size and do not coerce to arrays.

0 commit comments

Comments
 (0)