Re: [rust-dev] Define copyable types for [T, ..2] static vector initialization

2013-12-09 Thread Niko Matsakis
On Sat, Nov 30, 2013 at 12:53:24AM -0500, Ashish Myles wrote: > I have been waiting on integer parameters on traits since I first ran > into Rust, but the rust team might be avoiding that to prevent getting > Turing complete generics/templates. I assume we'll get to it eventually. Niko _

Re: [rust-dev] Define copyable types for [T, ..2] static vector initialization

2013-11-29 Thread Ashish Myles
+1 on specifying function. That potentially lowers the requirements on the Traits -- e.g. don't have to force clone-ability as long as you can create+move it; perhaps even create it in place. I have been waiting on integer parameters on traits since I first ran into Rust, but the rust team might b

Re: [rust-dev] Define copyable types for [T, ..2] static vector initialization

2013-11-29 Thread Kevin Ballard
Personally, I think it would be nicer to just have a syntax that says "create an array of length N by executing the following expression (typically a function call) N times". Something along the lines of let ary = [Foo::new().., ..32]; This would be more generic, because it will work with

Re: [rust-dev] Define copyable types for [T, ..2] static vector initialization

2013-11-29 Thread Ashish Myles
That's some seriously nifty stuff, which got my stuff compiling again. :) But for the long term, it would be nice to have a syntax that behaves as was the case with the Copy trait -- it takes a single value and clones it into the elements of the static array. Or perhaps the developers disagree an

Re: [rust-dev] Define copyable types for [T, ..2] static vector initialization

2013-11-29 Thread Kevin Ballard
If you're willing to use unsafe code and std::unstable, you can do it. use std::num::Zero; use std::unstable::intrinsics; enum Constants { SZ = 2 } struct Foo([T, ..SZ]); impl Foo { pub fn new() -> Foo { let mut ary: [T, ..SZ]; unsafe { ary = intrinsics::unin

Re: [rust-dev] Define copyable types for [T, ..2] static vector initialization

2013-11-29 Thread Ashish Myles
Is there a plan to support fix-sized vector initialization without manual replication? My example is just a simplified version -- this was part of a macro that takes the size as input ($n:expr) and the initialization was [Zero::zero(), .. $n]. Is this use case no longer intended to be supported?

Re: [rust-dev] Define copyable types for [T, ..2] static vector initialization

2013-11-29 Thread Huon Wilson
On 30/11/13 10:33, Ashish Myles wrote: Previously we had the Copy trait, which when implemented by trait T allowed one to write [Zero::zero(), ..SZ] where T implemented the Zero trait. But now I am not sure how to get that behavior. Concretely, here is the code I want to get compiling. (Just to

Re: [rust-dev] Define copyable types for [T, ..2] static vector initialization

2013-11-29 Thread Daniel Micay
On Fri, Nov 29, 2013 at 6:33 PM, Ashish Myles wrote: > Previously we had the Copy trait, which when implemented by trait T > allowed one to write > [Zero::zero(), ..SZ] where T implemented the Zero trait. But now I am > not sure how to get that behavior. Concretely, here is the code I > want to