[rust-dev] Copyability and repeated vector expressions

Patrick Walton pwalton at mozilla.com
Wed Jul 10 14:59:54 PDT 2013

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.



More information about the Rust-dev mailing list