Skip to content

Commit 1d72212

Browse files
committed
Refactor array-expr to consider the repeat count a const argument
1 parent 8c1a585 commit 1d72212

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/expressions/array-expr.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ArrayExpression -> `[` ArrayElements? `]`
99
1010
ArrayElements ->
1111
Expression ( `,` Expression )* `,`?
12-
| Expression `;` Expression
12+
| Expression `;` GenericArgsConst
1313
```
1414

1515
r[expr.array.constructor]
@@ -26,16 +26,16 @@ r[expr.array.array-behavior]
2626
This produces an array containing each of these values in the order they are written.
2727

2828
r[expr.array.repeat]
29-
The syntax for the second form is two expressions separated by a semicolon (`;`) enclosed in square brackets.
29+
The syntax for the second form is an expression and a const argument separated by a semicolon (`;`) enclosed in square brackets.
3030

3131
r[expr.array.repeat-operand]
3232
The expression before the `;` is called the *repeat operand*.
3333

3434
r[expr.array.length-operand]
35-
The expression after the `;` is called the *length operand*.
35+
The const argument after the `;` is called the *length operand*.
3636

3737
r[expr.array.length-restriction]
38-
It must have type `usize` and be a [constant expression], such as a [literal] or a [constant item].
38+
It must be a [const argument] of type `usize`.
3939

4040
r[expr.array.repeat-behavior]
4141
An array expression of this form creates an array with the length of the value of the length operand with each element being a copy of the repeat operand.
@@ -111,7 +111,7 @@ The array index expression can be implemented for types other than arrays and sl
111111
[IndexMut]: std::ops::IndexMut
112112
[Index]: std::ops::Index
113113
[array]: ../types/array.md
114-
[constant expression]: ../const_eval.md#constant-expressions
114+
[const argument]: ../items/generics.md
115115
[constant item]: ../items/constant-items.md
116116
[literal]: ../tokens.md#literals
117117
[memory location]: ../expressions.md#place-expressions-and-value-expressions

0 commit comments

Comments
 (0)