On Fri, Nov 29, 2013 at 6:33 PM, Ashish Myles <[email protected]> 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 check, I added both Clone and
> DeepClone, even though they don't automatically allow implicit
> copyability).
>
> ----
> use std::num::Zero;
>
> enum Constants {
>     SZ = 2
> }
>
> struct Foo<T>([T, ..SZ]);
>
> impl<T : Clone + DeepClone + Zero> Foo<T> {
>     pub fn new() -> Foo<T> {
>         Foo([Zero::zero(), ..SZ])
>     }
> }
> ----
>
> The error I get is:
>
> error: copying a value of non-copyable type `T`
> tmp.rs:155         Foo([Zero::zero(), ..SZ])
>
>
> Any way to do this? Or is this no longer supported for general types?
> Any intentions to add this behavior again?  Otherwise, I can't even
> initialize my struct while being agnostic to the specific value of SZ.
>
> Ashish

The `Clone` and `DeepClone` traits are defined entirely in the
standard library. Of course, another issue is that fixed-size vectors
can't have methods implemented on them at the moment.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to