File tree 1 file changed +10
-0
lines changed
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,16 @@ b]` creates an array containing `b` copies of the value of `a`. If the
21
21
expression after the semicolon has a value greater than 1 then this requires
22
22
that the type of ` a ` is [ ` Copy ` ] , or ` a ` must be a path to a constant item.
23
23
24
+ When the repeat expression ` a ` is a constant item, it is evaluated ` b ` times.
25
+ If ` b ` is 0, the constant item is not evaluated at all. For expressions that
26
+ are not a constant item, it is evaluated exactly once, and then the result is
27
+ copied ` b ` times.
28
+
29
+ > ** Note:** In the case where ` b ` is 0, and ` a ` is a non-constant item, there
30
+ > is currently a bug in ` rustc ` where the value ` a ` is evaluated but not
31
+ > dropped, thus causing a leak. See [ issue
32
+ > #74836 ] ( https://github.com/rust-lang/rust/issues/74836 ) .
33
+
24
34
``` rust
25
35
[1 , 2 , 3 , 4 ];
26
36
[" a" , " b" , " c" , " d" ];
You can’t perform that action at this time.
0 commit comments