# Pre-RFC: Array expansion syntax

**URL:** <https://internals.rust-lang.org/t/pre-rfc-array-expansion-syntax/13490>\
**Category:** language design\
**Created:** [December 1, 2020, 4:13pm UTC](https://internals.rust-lang.org/t/pre-rfc-array-expansion-syntax/13490 "2020-12-01T16:13:59Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![scottmcm](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/scottmcm/32/2355_2.png) [@scottmcm](https://internals.rust-lang.org/u/scottmcm)\
**Post date:** [December 1, 2020, 5:08pm UTC](https://internals.rust-lang.org/t/pre-rfc-array-expansion-syntax/13490/3 "2020-12-01T17:08:26Z")

</div>

This reminds me of tuple splatting, such as [Splats and tuples - Crystal](https://crystal-lang.org/reference/syntax_and_semantics/splats_and_tuples.html#splatting-a-tuple) -- should it work for that as well? Is there anything specific about arrays here? What about mixing? Can I convert a `let p = (1, 2);` into an array with `[...p]`?

> [@nwn](#):
>
> The biggest drawback is that this is a breaking change to the language.

It's not at all clear to me that a breaking change here is worth it. Why not just use three dots, say, like C++ parameter pack expansion? (Oh, and like in javascript, you mention later.)

The FRU parallel here doesn't feel that strong to me, since FRU is the same type, but this almost never would be (it wouldn't be illegal, but `[..a]` would just be `a`). In fact, the FRU parallel might have me expect that `[1, ..[0;3]]` is `[1, 0, 0]` because it only uses the _rest_ of the elements. (If you think of an array as a tuple struct with homogeneous fields and `repr(C)`, then `['a', ..['b';3]]` is `Array3 { 0: 'a', ..Array3('b', 'b', 'b') }` =\> `Array3('a', 'b', 'b')`, not something producing `Array4`.)

> [@nwn](#):
>
> Yet in current Rust, there's no way to express array concatenation at compile time. Even with the eventual stabilization of `const` library features like `copy_from_slice` , the user must specify the length of the resulting array, which is not necessarily known to them (though it is always to the compiler).

I would expect `const fn concat_arrays<T, N: usize, M: usize>(a: [T; N], b: [T; M]) -> [T; {N+M}]` to work eventually, which would not require that the user specify the length of the resulting array.

Now, that doesn't necessarily mean this is a bad feature, but I'm not convinced by this part of the motivation.

---

_[View the full topic](https://internals.rust-lang.org/t/pre-rfc-array-expansion-syntax/13490)._
