[rust-dev] Copyability and repeated vector expressions

Daniel Micay danielmicay at gmail.com
Wed Jul 10 15:44:26 PDT 2013


On Wed, Jul 10, 2013 at 6:38 PM, Daniel Micay <danielmicay at gmail.com> wrote:
> On Wed, Jul 10, 2013 at 5:59 PM, Patrick Walton <pwalton at mozilla.com> wrote:
>> Hi everyone,
>>
>> Currently there's a problem with repeated vector expressions (`[0, ..n]`):
>> the value must be copyable. I would like to change this to implicit
>> copyability changing as part of the migration to `Clone`, which makes this
>> even more restrictive.
>>
>> This makes it impossible (without writing a very long literal) to have
>> something reasonable like `[None, ..4096]` with the value as `Option<~T>`,
>> since `Option<~T>` is not implicitly copyable.
>>
>> The easiest way that I can see to fix this is to treat `EXPR` in `[EXPR,
>> ..COUNT]` as evaluated once for each `COUNT`. Essentially it becomes a
>> thunk. This makes me slightly nervous, but I don't see anything wrong with
>> it semantically.
>>
>> Thoughts?
>>
>> Patrick
>
> How about we start by allowing the subset of expressions that are
> constant expressions? I think it would be a reasonable limitation.

Actually, I guess that doesn't matter if we're using `Clone`... but
how would it work in constants?


More information about the Rust-dev mailing list