File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 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
2121expression after the semicolon has a value greater than 1 then this requires
2222that the type of ` a ` is [ ` Copy ` ] , or ` a ` must be a path to a constant item.
2323
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+
2434``` rust
2535[1 , 2 , 3 , 4 ];
2636[" a" , " b" , " c" , " d" ];
You can’t perform that action at this time.
0 commit comments