From dc9732620d21835176638ef7c443e04c708dcfdc Mon Sep 17 00:00:00 2001 From: Coca162 Date: Mon, 27 Feb 2023 13:51:10 +0000 Subject: [PATCH 1/2] Update docs to show [expr; N] can repeat const expr --- library/core/src/primitive_docs.rs | 6 ++++-- library/std/src/primitive_docs.rs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs index d6e9da187e80a..f04963f06afbe 100644 --- a/library/core/src/primitive_docs.rs +++ b/library/core/src/primitive_docs.rs @@ -587,8 +587,10 @@ mod prim_pointer {} /// There are two syntactic forms for creating an array: /// /// * A list with each element, i.e., `[x, y, z]`. -/// * A repeat expression `[x; N]`, which produces an array with `N` copies of `x`. -/// The type of `x` must be [`Copy`]. +/// * A repeat expression `[expr; N]` where `N` is how many times to repeat `expr` in the array. `expr` must either be: +/// +/// * A value of type `Copy` +/// * A `const` value /// /// Note that `[expr; 0]` is allowed, and produces an empty array. /// This will still evaluate `expr`, however, and immediately drop the resulting value, so diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index d6e9da187e80a..f04963f06afbe 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -587,8 +587,10 @@ mod prim_pointer {} /// There are two syntactic forms for creating an array: /// /// * A list with each element, i.e., `[x, y, z]`. -/// * A repeat expression `[x; N]`, which produces an array with `N` copies of `x`. -/// The type of `x` must be [`Copy`]. +/// * A repeat expression `[expr; N]` where `N` is how many times to repeat `expr` in the array. `expr` must either be: +/// +/// * A value of type `Copy` +/// * A `const` value /// /// Note that `[expr; 0]` is allowed, and produces an empty array. /// This will still evaluate `expr`, however, and immediately drop the resulting value, so From 22b65fc27594d5f95195ea098bfb0a60d21225d2 Mon Sep 17 00:00:00 2001 From: Coca162 Date: Mon, 27 Feb 2023 15:16:39 +0000 Subject: [PATCH 2/2] Clarify that Copy is a trait in array docs --- library/core/src/primitive_docs.rs | 2 +- library/std/src/primitive_docs.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs index f04963f06afbe..6f78811a186c7 100644 --- a/library/core/src/primitive_docs.rs +++ b/library/core/src/primitive_docs.rs @@ -589,7 +589,7 @@ mod prim_pointer {} /// * A list with each element, i.e., `[x, y, z]`. /// * A repeat expression `[expr; N]` where `N` is how many times to repeat `expr` in the array. `expr` must either be: /// -/// * A value of type `Copy` +/// * A value of a type implementing the [`Copy`] trait /// * A `const` value /// /// Note that `[expr; 0]` is allowed, and produces an empty array. diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index f04963f06afbe..6f78811a186c7 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -589,7 +589,7 @@ mod prim_pointer {} /// * A list with each element, i.e., `[x, y, z]`. /// * A repeat expression `[expr; N]` where `N` is how many times to repeat `expr` in the array. `expr` must either be: /// -/// * A value of type `Copy` +/// * A value of a type implementing the [`Copy`] trait /// * A `const` value /// /// Note that `[expr; 0]` is allowed, and produces an empty array.