You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/expressions/array-expr.md
+5-4Lines changed: 5 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -53,16 +53,16 @@ An array expression of this form creates an array with the length of the value o
53
53
That is, `[a; b]` creates an array containing `b` copies of the value of `a`.
54
54
55
55
r[expr.array.repeat-copy]
56
-
If the length operand has a value greater than 1 then this requires that the type of the repeat operand is [`Copy`] or that it must be a [path] to a constant item.
56
+
If the length operand has a value greater than 1 then this requires the repeat operand to have a type that implements [`Copy`], to be a [const block expression], or to be a [path] to a constant item.
57
57
58
58
r[expr.array.repeat-const-item]
59
-
When the repeat operand is a constant item, it is evaluated the length operand's value times.
59
+
When the repeat operand is a const block or a path to a constant item, it is evaluated the number of times specified in the length operand.
60
60
61
61
r[expr.array.repeat-evaluation-zero]
62
-
If that value is `0`, then the constant item is not evaluated at all.
62
+
If that value is `0`, then the const block or constant item is not evaluated at all.
63
63
64
64
r[expr.array.repeat-non-const]
65
-
For expressions that are not a constant item, it is evaluated exactly once, and then the result is copied the length operand's value times.
65
+
For expressions that are neither a const block nor a path to a constant item, it is evaluated exactly once, and then the result is copied the length operand's value times.
66
66
67
67
```rust
68
68
[1, 2, 3, 4];
@@ -123,6 +123,7 @@ The array index expression can be implemented for types other than arrays and sl
0 commit comments