Skip to content

Commit eb816ee

Browse files
committed
auto merge of #17535 : Manishearth/rust/patch-2, r=steveklabnik
It's a rather useful syntax, and non-obvious. A friend of mine is learning Rust and was trying to find a way to easily do such an initialization — he couldn't find it in the guide and was pretty surprised when I showed him. Looks like something that should be mentioned. r? @steveklabnik
2 parents b9478ee + 1f4cd80 commit eb816ee

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/doc/guide.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,7 @@ You can create an array with just square brackets:
15071507

15081508
```{rust}
15091509
let nums = [1i, 2i, 3i];
1510+
let nums = [1i, ..20]; // Shorthand for an array of 20 elements all initialized to 1
15101511
```
15111512

15121513
So what's the difference? An array has a fixed size, so you can't add or

0 commit comments

Comments
 (0)