about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCoca162 <coca16622@gmail.com>2023-02-27 13:51:10 +0000
committerCoca162 <coca16622@gmail.com>2023-02-27 13:51:10 +0000
commitdc9732620d21835176638ef7c443e04c708dcfdc (patch)
tree4ff26dac79fdea72edf1e9a419af46daa4badad5
parent49b9cc5139dd4d11ef78dc08c1f9170de5b1ca39 (diff)
downloadrust-dc9732620d21835176638ef7c443e04c708dcfdc.tar.gz
rust-dc9732620d21835176638ef7c443e04c708dcfdc.zip
Update docs to show [expr; N] can repeat const expr
-rw-r--r--library/core/src/primitive_docs.rs6
-rw-r--r--library/std/src/primitive_docs.rs6
2 files changed, 8 insertions, 4 deletions
diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs
index d6e9da187e8..f04963f06af 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 d6e9da187e8..f04963f06af 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